c++-standard-library

What should I use instead of sscanf?

I have a problem that sscanf solves (extracting things from a string). I don't like sscanf though since it's not type-safe and is old and horrible. I want to be clever and use some more modern parts of the C++ standard library. What should I use instead? ...

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++? ...

VC choosing the wrong operator<< overload only at the first call. Bug?

I spent some time removing all the uninfluent code and here is my problem. --- File.h --- #include <fstream> #include <string> template <typename Element> class DataOutput : public std::basic_ofstream<Element> { public: DataOutput(const std::string &strPath, bool bAppend, bool bBinary) : std::basic_ofstream<Element>( s...

How can I use a std::valarray to store/manipulate a contiguous 2D array?

How can I use a std::valarray to store/manipulate a 2D array? I'd like to see an example of a 2D array with elements accessed by row/column indices. Something like this pseudo code: matrix(i,j) = 42; An example of how to initialize such an array would also be nice. N.B.: I'm already aware of Boost.MultiArray, Boost.uBlas, and Blitz++...

Understanding the library functions in c++

If I'd like to know how a function written in like standard C++ library work (not just the MSDN description). I mean how does it allocate, manage, deallocate memory and return you the result. where or what do you need to know to understand that? ...

Lookin' for a container and memory pool solution...

In an embedded program I have a screen object that needs to manage a list of items to display. The initial list of items will be pulled from a simple DB on screen load and the list will be updated via "Add" and "Remove" events. This list needs to be sorted according to certain criteria. I am looking of a container class that can help me ...

std::string.resize() and std::string.length()

I'm relatively new to C++ and I'm still getting to grips with the C++ Standard Library. To help transition from C, I want to format a std::string using printf-style formatters. I realise stringstream is a more type-safe approach, but I find myself finding printf-style much easier to read and deal with (at least, for the time being). This...

Qt: Qt classes vs. standard C++

A large amount of functionality is duplicated between standard c++ and Qt. At some point it seems logical but many times it looks foolish. Like I feel like doing a new programming language, learning things which I already know. e.g. using QFile. Also if I do it all Qt way and suppose now I want to move out of Qt framework it will be too...

Understanding the design of std::istream::read

std::istream has the prototype istream& read (char* s, streamsize n) the actual number of bytes read should be gotten by calling istream::gcount(), also the validity of the istream can be known from ios::good. I was discussing another stream class' implementation I was trying to write with a colleague of mine, where I was saying I might...