standard-library

Flash Standard Libraries?

For a new project with Flash I was looking for something along the lines of standard libraries for basic programming needs, along the lines of Python or Ruby standard libraries. But the only thing I found was a dead project on Sourceforge. Thus is there no standard library for flash? Does everyone reinvent the wheel each time? ...

Is there a way to check if an istream was opened in binary mode?

I'm using an istream which could be stringstream, ifstream or a user-defined stream type and I need to know if, in the case of an ifstream, it was not opened in binary mode (so I can throw an exception). I have tried the following method: if ((_is.flags() & ios::binary) == 0) throw exception(...) but no exception is ever thrown. T...

Collections.max function for iterable<Integer> in java

The Java Collections.max takes only a collection of a sortable object. However since the collection is not necessarily sorted, I don't see any reason not to implement the same max function for iterable types. Is there a max method for Iterable<T extends Comparable<? super T>> in java's standard library? ...

trim is not part of the standard c/c++ library ?

Is it me or are there no standard trim functions in the c or c++ library? is there any single function that acts as a trim? If not can anyone tell me Why trim is not part of the standard library? (i know trim is in boost) My trim code is std::string trim(const std::string &str) { size_t s = str.find_first_not_of(" \n\r\t"); siz...

Are these appropriate practices when working with std::map?

I have some questions on using std::map: Is using an enum as the key in std::map a good practice? Consider the following code: enum Shape{ Circle, Rectangle }; int main(int argc, char* argv[]) { std::map strMap; // strMap.insert(Shape::Circle,"Circle"); // This will not compile strMap[Shape::Circle] = "Circle"; ...

A question about auto_ptr

template<class Y> operator auto_ptr_ref<Y>() throw() { return auto_ptr_ref<Y>(release()); } It is part of implementation of class auto_ptr in standard library. What does this means to do? Why there is an "auto_ptr_ref" between "operator" and "()"? ...

How does memchr() work under the hood?

Background: I'm trying to create a pure D language implementation of functionality that's roughly equivalent to C's memchr but uses arrays and indices instead of pointers. The reason is so that std.string will work with compile time function evaluation. For those of you unfamiliar w/ D, functions can be evaluated at compile time if ce...

Good Idea / Bad Idea Should I Reimplement Most Of C++?

Recently, I've got a dangerous idea into my head after reading this blog post. That idea can be expressed like this: I don't need most of what the C++ standard library offers. So, why don't I implement a less general, but easier to use version? As an example, using the STL spits out reams of incomprehensible and mangled compiler errors...

How can I easily work with a char**?

I have a char** that I frequently need to insert into or perform a lookup. It is very tedious to realloc(), malloc() the array and insert strings. Is there any standard way that I can add strings to or do lookups in a char**? I guess I'm looking for something like string, but using char**'s instead. ...

What is the current status of D standard libraries?

There are two of them Phobos and Tango. As far as I know they are redundant and incompatible. Are there any plans to join them? If so, when will it happen? ...

How to workaround the inconsistent definition of numeric_limits<T>::min()?

The numeric_limits traits is supposed to be a general way of obtaining various type infomation, to be able to do things like template<typename T> T min(const std::vector<T>& vect) { T val = std::numeric_limits<T>::min(); for(int i=0 ; i<vect.size() ; i++) val = max(T, vect[i]); return val; } The problem is that (...

How can I get rid of the warning with rand()? (C++)

Whenever I use the rand function in C++: #include<iostream> #include<time.h> #include<stdlib.h> using namespace std; int main(){ srand(time(0)); int n=(rand()%6)+1; cout<<"The dice roll is "<<n<<"."<<endl; } I get a warning about conversion from time_t to int at line 5: srand(time(0)); Is there any way to get rid of this warning? ...

How do I use C++ STL containers in My iPhone App?

I'd like to use an STL set in my iPhone app (which is written in Objective-C in XCode). How do I include set and/or use the standard namespace? In C++ I'd do this: #include<set> using namespace std; // use the set<T> somewhere down here... How can I do this in Objective-C? ...

Where can I see the list of functions that interact with errno?

In the book "The C Programming Language" it says: "Many of the functions in the library set status indicators when error or end of file occur. These indicators may be set and tested explicitly. In addition, the integer expression errno (declared in <errno.h>) may contain an error number that gives further information about the mo...

How does Java make its windows?

How does the JVM make it's windows, i know it has it's jar files and the executables, etc... what i would like to know is how exactly is a window made with java, the frame surrounding a desktop application. is it a graphics library standard on the machines it is installed in? ...

Does C or C++ have a standard regex library?

Does it? If yes, where can I get the documentation for it... if not, then which would be the best alternative? ...

Most useful Python modules from the standard library?

I am teaching a graduate level Python class at the University of Paris, and the students need to be introduced to the standard library. I want to discuss with them about some of the most important standard modules. What modules do you think are absolute musts? Even though responses probably vary depending on your field (web programmin...

MSVC _open/_close/etc

Why are the API's _open, _close, and other standard file i/o functions prefixed with an underscore? Aren't these part of some standard? ...

which type of sorting is used in the function sort()?

Can anyone please tell me that which type of sorting technique (bubble, insertion, selection, quick, merge, count...) is implemented in the std::sort() function defined in the <algorithm> header file in C++? ...

SBCL standard library documentation?

I want to learn and use SBCL because of its ease of learning and speed. (I've been playing with Lisp 3 years ago, and now am refreshing it.) But how can I learn what's included in the standard library, so that I don't re-implement things? After Python this is like a nightmare: the SBCL website has a manual that covers the software only,...