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]

[libstdc++ PATCH] Implement __is_nothrow_swappable and use it


This patch partially solves the problem described in N4426, which is
basically LWG
issue 2456, which in turn is caused by CWG DR 1330. Some remarks:
- the __is_swappable and __is_nothrow_swappable are at this time not
meant to be general traits, they make the shortcut of automatically transforming
their template parameter into a reference, which the truly general trait
as described in N4426 wouldn't do.
- swap is now constrained..
- ..which means that everything from bits/move.h moves to type_traits since
swap now needs type_traits. type_traits becomes ok to include in pre-c++14
modes, but only enables the parts that work in pre-c++14 modes.
- this patch does _not_ yet implement N4426.

Tested on Linux-x64.

2015-05-01  Ville Voutilainen  <ville.voutilainen@gmail.com>
    Add __is_nothrow_swappable and take it into use.
    * libstdc++-v3/include/bits/algorithmfwd.h: Add constraints to the
    forward-declaration of swap.
    * include/bits/move.h: Move everything in it to..
    * include/type_traits: ..here.
    * include/type_traits (__swappable_impl::__swappable,
    __is_nothrow_swappable_impl, __is_nothrow_swappable): New.
    * include/bits/stl_pair.h (swap): Use __is_nothrow_swappable
    for the free swap function for pair.
    * include/bits/stl_queue.h (swap): Use __is_nothrow_swappable
    for the free swap functions for queue and priority_queue.
    * include/bits/stl_stack.h (swap): Use __is_nothrow_swappable
    for the free swap function for stack.
    * include/debug/array (swap): Use __is_nothrow_swappable
    for the free swap function for array.
    * include/profile/array (swap): Likewise.
    * include/std/array (swap): Likewise.
    * include/std/tuple (_M_swap): Use __is_nothrow_swappable.
    * testsuite/20_util/forward/c_neg.cc: Adjust.
    * testsuite/20_util/forward/f_neg.cc: Likewise.
    * testsuite/20_util/headers/type_traits/std_c++0x_neg.cc: Remove.
    * testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc:
New.
    * testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc: Likewise.
    * testsuite/20_util/is_nothrow_swappable/value.cc: Likewise.

Attachment: is_nothrow_swappable.diff
Description: Text document


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