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: noexcept move on containers (e.g. list)


On 18 September 2013 09:58, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> Hi Kenny,
>
> On 18 September 2013 05:42, Kenny Simpson wrote:
>> http://channel9.msdn.com/Events/GoingNative/2013/An-Effective-Cpp11-14-Sampler
>>
>> at 48:40, Scott goes into pointing out that none of the Standard containers are defined as having noexcept move constructors, and that fishing around in the Standard library will show very few noexcept things... but as of current trunk, I do see that many of these noexcept specifiers were added in 2011 (c95bf15b in the git mirror).
>>
>> STL explains something about why these are not noexcept in the Standard (and presumably also in VC++'s library), but the audio is too low for me to make out what he says.
>
> I haven't seen the video, but he might be referring to the guidelines
> used in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3279.pdf
> which say that functions should only be unconditionally noexcept if
> they have no preconditions.  So e.g. vector::operator[](size_type n)
> cannot be noexcept because it has a precondition that n < size().
>
> The rule is used throughout the standard library and is meant to allow
> debugging implementations or testing frameworks that check
> preconditions and indicate violations by throwing exceptions.

Although as you're asking specifically about move constructors (which
I don't think we check any preconditions on anyway) I don't know why
the standard considers them to have narrow contracts.


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