Why is there no piecewise tuple construction?

Question: Why doesn’t the same piecewise constructibility exist for arrays and tuples? My recollection is that piecewise construction was added to std::pair for one reason only: to support uses-allocator construction of the pair elements, i.e. to allow an allocator to be provided and conditionally passed to the elements if they support construction with an allocator … Read more

Is std::array movable?

std::array is movable only if its contained objects are movable. std::array is quite different from the other containers because the container object contains the storage, not just pointers into the heap. Moving a std::vector only copies some pointers, and the contained objects are none the wiser. Yes, std::array uses the default move constructor and assignment … Read more

Raw pointer lookup for sets of unique_ptrs

In C++14, std::set<Key>::find is a template function if Compare::is_transparent exists. The type you pass in does not need to be Key, just equivalent under your comparator. So write a comparator: template<class T> struct pointer_comp { typedef std::true_type is_transparent; // helper does some magic in order to reduce the number of // pairs of types we … Read more

unique_ptr boost equivalent?

It’s not possible to create something like unique_ptr without C++0x (where it’s part of the standard library, and so Boost doesn’t need to provide it). Specifically without rvalue references, which are a feature in C++0x, a robust implementation of unique_ptr is impossible, with or without Boost. In C++03, there are a few possible alternatives, although … Read more