
On 12 February 2013 14:02, Krzysztof Czainski <1czajnik@gmail.com> wrote:
2013/2/12 Nevin Liber <nevin@eviloverlord.com>
I am not familiar with C++11 initialization syntax details, I only read about that, and I'm stuck with C++03 for now. Are you suggesting, that this would mean adding a lot of (too many?) member functions?
There are some corner cases where list initialization behaves differently than direct initialization. Take the following example: template<typename T> struct ListInitializationAllocator { typedef T value_type; typedef typename std::aligned_storage<sizeof(T), alignof(T)>::type storage_type; T* allocate(size_t n) { return static_cast<T*>(static_cast<void*>(::new storage_type[n])); } void deallocate(T* p, size_t) { ::delete [] static_cast<storage_type*>(static_cast<void*>(p)); } template<typename... Args> void construct(T* c, Args&&... args) { ::new (static_cast<void*>(c)) T{ std::forward<Args>(args)... }; } }; vector<vector<int>> vd; vd.emplace_back(2); assert(2 == vd.back().size()); vector<vector<int>, ListInitializationAllocator<vector<int>>> vl; vl.emplace_back(2); assert(1 == vl.back().size()); The element in vd is a vector<int> of 2 elements which are value-initialized to 0. The element in vl is a vector<int> of 1 element copy-initialized to 2.
Anyway, personally I'm only interested in features, that can be added for C++03 ;-)
Boost needs to be more concerned than that.
And noinit_push*/noinit_resize (enabled_if< is_pod<value_type> >) are things I have use cases for.
That is the difference between designing a library for yourself and a library for the community at large. This use case might not be important enough to implement, but it should at least be considered. -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404