Is this behavior of vector::resize(size_type n) under C++11 and Boost.Container correct?

Not an answer, but a lengthy addendum to Howard’s: I use an allocator adapter that basically works the same as Howard’s allocator, but is safer since it only interposes on value-initialization and not all initializations, it correctly default-initializes. // Allocator adaptor that interposes construct() calls to // convert value initialization into default initialization. template <typename … Read more

How do you add Boost libraries in CMakeLists.txt?

Put this in your CMakeLists.txt file (change any options from OFF to ON if you want): set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.45.0 COMPONENTS *boost libraries here*) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) add_executable(progname file1.cxx file2.cxx) target_link_libraries(progname ${Boost_LIBRARIES}) endif() Obviously you need to put the libraries you want where I put *boost libraries here*. For example, if you’re … Read more

How to link C++ program with Boost using CMake

In CMake you could use find_package to find libraries you need. There usually is a FindBoost.cmake along with your CMake installation. As far as I remember, it will be installed to /usr/share/cmake/Modules/ along with other find-scripts for common libraries. You could just check the documentation in that file for more information about how it works. … Read more

smart pointers (boost) explained

Basic properties of smart pointers It’s easy when you have properties that you can assign each smart pointer. There are three important properties. no ownership at all transfer of ownership share of ownership The first means that a smart pointer cannot delete the object, because it doesn’t own it. The second means that only one … Read more

Fixed-size floating point types

Nothing like this exists in the C or C++ standards at present. In fact, there isn’t even a guarantee that float will be a binary floating-point format at all. Some compilers guarantee that the float type will be the IEEE-754 32 bit binary format. Some do not. In reality, float is in fact the IEEE-754 … Read more