This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why is allocator::construct() called with one argument for '--std=c++0x'?


On 11 November 2011 00:54, Jonathan Wakely wrote:
> On 10 November 2011 23:49, Syncopated wrote:
>>
>> I'm using gcc 4.6.2. I tried to compile a program involving TBB 3.0 with the
>> following line and got a compilation error.
>>
>> vector<int, tbb::cache_aligned_allocator<int> > values(0);
>>
>> It turns out that ?bits/stl_uninitialized.h is calling
>> allocator::construct() with only one argument, and
>> tbb::cache_aligned_allocator doesn't define it. AFAIK, construct() takes two
>> arguments. Is this something new in C++11, that construct() can take one
>> argument?
>
> Yes, the signature is now:
>
> template<class U, class... Args>
> ?void construct(U* p, Args&&... args);
>
> So can take any number of arguments, which are passed on to the constructor.
>
> However in C++11 calls to allocators should be done through
> allcoator_traits, which abstracts the differences between C++03
> allocators and C++11 allocators, so it will work with allocators that
> only support the old 2-argument construct() signature. ?Unfortunately
> we have only implemented allocator_traits in the unreleased GCC 4.7,
> i.e. the subversion trunk.
>
> In that code the code looks like this:
> ?__traits::construct(__alloc, std::__addressof(*__cur));
> instead of
> ?__alloc.construct(std::__addressof(*__cur));

I've opened a bug report for the problem in 4.6: http://gcc.gnu.org/PR51626


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]