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: std::pair copy and move constructor


2013/3/6 Daniel Krügler <daniel.kruegler@gmail.com>:
> 2013/3/6 François Dumont <frs.dumont@gmail.com>:
[..]
>>     That's indeed what I had in mind. And yes, limited to special methods, I
>> can't even imagine how it could be generalized to others.
>>
>>     Note that in the case of std::pair<cont int, double> the template
>> assignment operator would fail to compile too so it would be transparent.
>> The only difference would be that std::is_copy_assignable<std::pair<const
>> int, double>> would give the correct result. Add
>> std::is_copy_assignable<std::pair<int&, double>> too which is of course
>> std::false_type. So it would be very nice.
>
> I agree that this *could* be made to work via a such a core language
> extension. My personal hope is a slighter rule change of the standard
> library that would have the effect to allow that std::pair also can
> have a base class. With such an allowance it is possible to realize
> the same thing without any language change.

I would like to mention that I withdraw my proposal to submit a
library issue to allow to implement std::pair using a base class to
hold the data members, based on the test case

template <class T, class U, U T::*> struct A{};

which would break for

A<std::pair<int, int>, int, &std::pair<int, int>::first> a;

So I agree that a core language change would be useful.

- Daniel


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