diff options
author | Martin Jambor <mjambor@suse.cz> | 2016-06-29 16:53:56 +0000 |
---|---|---|
committer | Martin Jambor <mjambor@suse.cz> | 2016-06-29 16:53:56 +0000 |
commit | ab9b316a08275b1c14ea16dfc07d712bd2418124 (patch) | |
tree | 2aa803fc42e7bc2ac3587bcec19f3940485f1f60 /libstdc++-v3 | |
parent | daf404b27549e063255ae16e3df741c9031c2840 (diff) |
Merged trunk revision 237818 into the hsa branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/hsa@237856 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
83 files changed, 3576 insertions, 1235 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8ff4d16d0e3..c7e0b326ff8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,207 @@ +2016-06-27 François Dumont <fdumont@gcc.gnu.org> + + PR libstdc++/71640 + * include/bits/hashtable.h: Remove _Unique_keya parameter in _Insert + friend declaration. + +2016-06-23 François Dumont <fdumont@gcc.gnu.org> + + * include/debug/array (array<>::swap): Fix noexcept qualificaton for + zero-size array. + +2016-06-21 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> + + * configure.host: Remove mep-* support. + +2016-06-21 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> + + * configure: Regenerate. + * configure.host: Remove support for knetbsd. + * crossconfig.m4: Likewise. + +2016-06-20 François Dumont <fdumont@gcc.gnu.org> + + PR libstdc++/71181 + * include/tr1/hashtable_policy.h + (_Prime_rehash_policy::_M_next_bkt): Make past-the-end iterator + dereferenceable to avoid check on lower_bound result. + (_Prime_rehash_policy::_M_bkt_for_elements): Call latter. + (_Prime_rehash_policy::_M_need_rehash): Likewise. + * src/c++11/hashtable_c++0x.cc (_Prime_rehash_policy::_M_next_bkt): + Always return a value greater than input value. Set _M_next_resize to + max value when reaching highest prime number. + * src/shared/hashtable-aux.cc (__prime_list): Add comment about sentinel + being now useless. + * testsuite/23_containers/unordered_set/hash_policy/71181.cc: New. + * testsuite/23_containers/unordered_set/hash_policy/power2_rehash.cc + (test02): New. + * testsuite/23_containers/unordered_set/hash_policy/prime_rehash.cc: New. + * testsuite/23_containers/unordered_set/hash_policy/rehash.cc: + Fix indentation. + +2016-06-17 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71545 + * include/bits/stl_algobase.h (lower_bound, lexicographical_compare): + Remove irreflexive checks. + * include/bits/stl_algo.h (lower_bound, upper_bound, equal_range, + binary_search): Likewise. + * testsuite/25_algorithms/equal_range/partitioned.cc: New test. + * testsuite/25_algorithms/lexicographical_compare/71545.cc: New test. + * testsuite/25_algorithms/lower_bound/partitioned.cc: New test. + * testsuite/25_algorithms/upper_bound/partitioned.cc: New test. + * testsuite/util/testsuite_iterators.h (__gnu_test::test_container): + Add constructor from array. + +2016-06-16 François Dumont <fdumont@gcc.gnu.org> + + * include/debug/debug.h + (__glibcxx_requires_non_empty_range, __glibcxx_requires_nonempty) + (__glibcxx_requires_subscript): Move... + * include/debug/assertions.h: ...here and add __builtin_expect. + (_GLIBCXX_DEBUG_ONLY): Remove ; value. + * include/bits/stl_deque.h + (std::deque<>::operator[]): Add __glibcxx_requires_subscript check. + (std::deque<>::front()): Add __glibcxx_requires_nonempty check. + (std::deque<>::back()): Likewise. + (std::deque<>::pop_front()): Likewise. + (std::deque<>::pop_back()): Likewise. + (std::deque<>::swap(deque&)): Add allocator check. + * include/bits/stl_vector.h + (std::vector<>::operator[]): Add __glibcxx_requires_subscript check. + (std::vector<>::front()): Add __glibcxx_requires_nonempty check. + (std::vector<>::back()): Likewise. + (std::vector<>::pop_back()): Likewise. + (std::vector<>::swap(vector&)): Add allocator check. + +2016-06-16 Daniel Kruegler <daniel.kruegler@gmail.com> + + Provide swappable traits (p0185r1) + * include/std/type_traits (is_swappable, is_nothrow_swappable, + is_swappable_with, is_nothrow_swappable_with, is_swappable_v, + is_nothrow_swappable_v, is_swappable_with_v, + is_nothrow_swappable_with_v): New. + * include/bits/stl_pair.h: Use it as per p0185r1. + * include/bits/stl_queue.h: Likewise. + * include/bits/stl_stack.h: Likewise. + * include/bits/unique_ptr.h: Likewise. + * include/std/tuple: Likewise. + * include/std/array: Likewise. Fix zero-size member swap. + * include/bits/hashtable.h: Use __and_. + * testsuite/20_util/is_nothrow_swappable/requirements/ + explicit_instantiation.cc: Change test options to std=gnu++17. + * testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc: + Likewise. + * testsuite/20_util/is_nothrow_swappable/value.cc: Likewise. + * testsuite/20_util/is_swappable/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/is_swappable/requirements/typedefs.cc: Likewise. + * testsuite/20_util/is_swappable/value.cc: Likewise. + * testsuite/20_util/is_nothrow_swappable/requirements/ + explicit_instantiation_ext.cc: New. + * testsuite/20_util/is_nothrow_swappable/requirements/typedefs_ext.cc: + New. + * testsuite/20_util/is_nothrow_swappable/value.h: New. + * testsuite/20_util/is_nothrow_swappable/value_ext.cc: New. + * testsuite/20_util/is_nothrow_swappable_with/requirements/ + explicit_instantiation.cc: New. + * testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc: + New. + * testsuite/20_util/is_nothrow_swappable_with/value.cc: New. + * testsuite/20_util/is_swappable/requirements/ + explicit_instantiation_ext.cc: New. + * testsuite/20_util/is_swappable/requirements/typedefs_ext.cc: New. + * testsuite/20_util/is_swappable/value.h: New. + * testsuite/20_util/is_swappable/value_ext.cc: New. + * testsuite/20_util/is_swappable_with/requirements/ + explicit_instantiation.cc: New. + * testsuite/20_util/is_swappable_with/requirements/typedefs.cc: New. + * testsuite/20_util/is_swappable_with/value.cc: New. + * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust + dg-error line numbers. + * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc: + Likewise. + +2016-06-16 Jonathan Wakely <jwakely@redhat.com> + + * include/std/array: Remove trailing whitespace. + * include/std/atomic: Likewise. + * include/std/bitset: Likewise. + * include/std/chrono: Likewise. + * include/std/complex: Likewise. + * include/std/condition_variable: Likewise. + * include/std/fstream: Likewise. + * include/std/functional: Likewise. + * include/std/future: Likewise. + * include/std/iomanip: Likewise. + * include/std/iosfwd: Likewise. + * include/std/istream: Likewise. + * include/std/limits: Likewise. + * include/std/ratio: Likewise. + * include/std/scoped_allocator: Likewise. + * include/std/sstream: Likewise. + * include/std/stdexcept: Likewise. + * include/std/string: Likewise. + * include/std/system_error: Likewise. + * include/std/thread: Likewise. + * include/std/tuple: Likewise. + * include/std/type_traits: Likewise. + * include/std/utility: Likewise. + * include/std/valarray: Likewise. + * include/std/vector: Likewise. + + * include/bits/stl_vector.h (vector::_S_insert_aux_assign): Define + new overloaded functions. + * include/bits/vector.tcc (vector::_M_insert_aux): Use new functions + to avoid creating a redundant temporary. + * testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc: New + test. + +2016-06-15 François Dumont <fdumont@gcc.gnu.org> + + * include/bits/stl_deque.h + (std::deque<>::operator=): Call _M_assign_aux. + (std::deque<>::assign(initializer_list<>)): Likewise. + (std::deque<>::resize(size_t, const value_type&)): Call _M_fill_insert. + (std::deque<>::insert(const_iterator, initializer_list<>)): + Call _M_range_insert_aux. + (std::deque<>::_M_assign_aux<It>(It, It, std::forward_iterator_tag): + Likewise. + (std::deque<>::_M_fill_assign): Call _M_fill_insert. + (std::deque<>::_M_move_assign2): Call _M_assign_aux. + * include/bits/deque.tcc + (std::deque<>::operator=): Call _M_range_insert_aux. + (std::deque<>::_M_assign_aux<It>(It, It, std::input_iterator_tag)): + Likewise. + * include/bits/stl_vector.h + (std::vector<>::operator=): Call _M_assign_aux. + (std::vector<>::assign(initializer_list<>)): Likewise. + (std::vector<>::resize(size_t, const value_type&)): Call _M_fill_insert. + (std::vector<>::insert(const_iterator, initializer_list<>)): + Call _M_range_insert. + * include/bits/vector.tcc (std::vector<>::_M_assign_aux): Likewise. + +2016-06-07 François Dumont <fdumont@gcc.gnu.org> + + * include/std/tuple (_Head_base<>): Default specialization condition at + type declaration. + +2016-06-06 Ville Voutilainen <ville.voutilainen@gmail.com> + + Support allocators in tuples of zero size. + * include/std/tuple (tuple<>::tuple(), + tuple<>::tuple(allocator_arg_t, const _Alloc&), + tuple<>::tuple(allocator_arg_t, const _Alloc&, const tuple&)): New. + * testsuite/20_util/tuple/cons/allocators.cc: Adjust. + +2016-06-06 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71320 + * src/filesystem/ops.cc (permissions(const path&, perms, error_code&)): + Add or remove permissions according to perms argument. + * testsuite/experimental/filesystem/operations/permissions.cc: New + test. + 2016-06-05 Ville Voutilainen <ville.voutilainen@gmail.com> Protect allocator-overloads of tuple-from-tuple constructors diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 4e811665a80..fcbf4029cf8 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -53544,7 +53544,7 @@ $as_echo "#define HAVE_TLS 1" >>confdefs.h ;; esac ;; - *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-knetbsd*-gnu | *-cygwin*) + *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-cygwin*) # All these tests are for C++; save the language and the compiler flags. # The CXXFLAGS thing is suspicious, but based on similar bits previously diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host index 0b366eafaae..c0cc3ee1285 100644 --- a/libstdc++-v3/configure.host +++ b/libstdc++-v3/configure.host @@ -114,10 +114,6 @@ case "${host_cpu}" in hppa*) try_cpu=hppa ;; - mep*) - EXTRA_CXX_FLAGS=-mm - try_cpu=generic - ;; mips*) try_cpu=mips ;; @@ -265,7 +261,7 @@ case "${host_os}" in linux-musl*) os_include_dir="os/generic" ;; - gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) + gnu* | linux* | kfreebsd*-gnu) if [ "$uclibc" = "yes" ]; then os_include_dir="os/uclibc" elif [ "$bionic" = "yes" ]; then diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 index ece12567794..6abc84f8c43 100644 --- a/libstdc++-v3/crossconfig.m4 +++ b/libstdc++-v3/crossconfig.m4 @@ -149,7 +149,7 @@ case "${host}" in ;; esac ;; - *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-knetbsd*-gnu | *-cygwin*) + *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-cygwin*) GLIBCXX_CHECK_COMPILER_FEATURES GLIBCXX_CHECK_LINKER_FEATURES GLIBCXX_CHECK_MATH_SUPPORT diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index b1dab643f35..96ec9f82d8f 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -119,7 +119,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { const_iterator __mid = __x.begin() + difference_type(__len); std::copy(__x.begin(), __mid, this->_M_impl._M_start); - insert(this->_M_impl._M_finish, __mid, __x.end()); + _M_range_insert_aux(this->_M_impl._M_finish, __mid, __x.end(), + std::random_access_iterator_tag()); } } return *this; @@ -280,7 +281,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER if (__first == __last) _M_erase_at_end(__cur); else - insert(end(), __first, __last); + _M_range_insert_aux(end(), __first, __last, + std::__iterator_category(__first)); } template <typename _Tp, typename _Alloc> diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 5748920cc78..6d7134a8a30 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -294,7 +294,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename _ExtractKeya, typename _Equala, typename _H1a, typename _H2a, typename _Hasha, typename _RehashPolicya, typename _Traitsa, - bool _Constant_iteratorsa, bool _Unique_keysa> + bool _Constant_iteratorsa> friend struct __detail::_Insert; public: @@ -475,8 +475,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void swap(_Hashtable&) - noexcept(__is_nothrow_swappable<_H1>::value - && __is_nothrow_swappable<_Equal>::value); + noexcept(__and_<__is_nothrow_swappable<_H1>, + __is_nothrow_swappable<_Equal>>::value); // Basic container operations iterator @@ -1236,8 +1236,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>:: swap(_Hashtable& __x) - noexcept(__is_nothrow_swappable<_H1>::value - && __is_nothrow_swappable<_Equal>::value) + noexcept(__and_<__is_nothrow_swappable<_H1>, + __is_nothrow_swappable<_Equal>>::value) { // The only base class with member variables is hash_code_base. // We define _Hash_code_base::_M_swap because different diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index fbd03a79e1e..c2ac0317f17 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -2026,7 +2026,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_ForwardIterator>::value_type, _Tp>) __glibcxx_requires_partitioned_lower_pred(__first, __last, __val, __comp); - __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); return std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_comp_val(__comp)); @@ -2080,7 +2079,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanOpConcept< _Tp, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_partitioned_upper(__first, __last, __val); - __glibcxx_requires_irreflexive2(__first, __last); return std::__upper_bound(__first, __last, __val, __gnu_cxx::__ops::__val_less_iter()); @@ -2112,7 +2110,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_partitioned_upper_pred(__first, __last, __val, __comp); - __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); return std::__upper_bound(__first, __last, __val, __gnu_cxx::__ops::__val_comp_iter(__comp)); @@ -2186,7 +2183,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_partitioned_lower(__first, __last, __val); __glibcxx_requires_partitioned_upper(__first, __last, __val); - __glibcxx_requires_irreflexive2(__first, __last); return std::__equal_range(__first, __last, __val, __gnu_cxx::__ops::__iter_less_val(), @@ -2225,7 +2221,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __val, __comp); __glibcxx_requires_partitioned_upper_pred(__first, __last, __val, __comp); - __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); return std::__equal_range(__first, __last, __val, __gnu_cxx::__ops::__iter_comp_val(__comp), @@ -2255,7 +2250,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_partitioned_lower(__first, __last, __val); __glibcxx_requires_partitioned_upper(__first, __last, __val); - __glibcxx_requires_irreflexive2(__first, __last); _ForwardIterator __i = std::__lower_bound(__first, __last, __val, @@ -2291,7 +2285,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __val, __comp); __glibcxx_requires_partitioned_upper_pred(__first, __last, __val, __comp); - __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); _ForwardIterator __i = std::__lower_bound(__first, __last, __val, diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index d95ea513a59..210b1734545 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -989,7 +989,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanOpConcept< typename iterator_traits<_ForwardIterator>::value_type, _Tp>) __glibcxx_requires_partitioned_lower(__first, __last, __val); - __glibcxx_requires_irreflexive2(__first, __last); return std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_less_val()); @@ -1214,9 +1213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) __glibcxx_requires_valid_range(__first1, __last1); - __glibcxx_requires_irreflexive2(__first1, __last1); __glibcxx_requires_valid_range(__first2, __last2); - __glibcxx_requires_irreflexive2(__first2, __last2); return std::__lexicographical_compare_aux(std::__niter_base(__first1), std::__niter_base(__last1), @@ -1246,9 +1243,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_InputIteratorConcept<_II1>) __glibcxx_function_requires(_InputIteratorConcept<_II2>) __glibcxx_requires_valid_range(__first1, __last1); - __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); __glibcxx_requires_valid_range(__first2, __last2); - __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); return std::__lexicographical_compare_impl (__first1, __last1, __first2, __last2, diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index d7a9d523e3a..66b8da6a854 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -63,6 +63,8 @@ #include <initializer_list> #endif +#include <debug/assertions.h> + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_CONTAINER @@ -1081,7 +1083,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER deque& operator=(initializer_list<value_type> __l) { - this->assign(__l.begin(), __l.end()); + _M_assign_aux(__l.begin(), __l.end(), + random_access_iterator_tag()); return *this; } #endif @@ -1142,7 +1145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ void assign(initializer_list<value_type> __l) - { this->assign(__l.begin(), __l.end()); } + { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } #endif /// Get a copy of the memory allocation object. @@ -1306,7 +1309,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { const size_type __len = size(); if (__new_size > __len) - insert(this->_M_impl._M_finish, __new_size - __len, __x); + _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x); else if (__new_size < __len) _M_erase_at_end(this->_M_impl._M_start + difference_type(__new_size)); @@ -1328,7 +1331,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { const size_type __len = size(); if (__new_size > __len) - insert(this->_M_impl._M_finish, __new_size - __len, __x); + _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x); else if (__new_size < __len) _M_erase_at_end(this->_M_impl._M_start + difference_type(__new_size)); @@ -1364,7 +1367,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ reference operator[](size_type __n) _GLIBCXX_NOEXCEPT - { return this->_M_impl._M_start[difference_type(__n)]; } + { + __glibcxx_requires_subscript(__n); + return this->_M_impl._M_start[difference_type(__n)]; + } /** * @brief Subscript access to the data contained in the %deque. @@ -1379,7 +1385,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ const_reference operator[](size_type __n) const _GLIBCXX_NOEXCEPT - { return this->_M_impl._M_start[difference_type(__n)]; } + { + __glibcxx_requires_subscript(__n); + return this->_M_impl._M_start[difference_type(__n)]; + } protected: /// Safety check used only from at(). @@ -1436,7 +1445,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ reference front() _GLIBCXX_NOEXCEPT - { return *begin(); } + { + __glibcxx_requires_nonempty(); + return *begin(); + } /** * Returns a read-only (constant) reference to the data at the first @@ -1444,7 +1456,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ const_reference front() const _GLIBCXX_NOEXCEPT - { return *begin(); } + { + __glibcxx_requires_nonempty(); + return *begin(); + } /** * Returns a read/write reference to the data at the last element of the @@ -1453,6 +1468,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER reference back() _GLIBCXX_NOEXCEPT { + __glibcxx_requires_nonempty(); iterator __tmp = end(); --__tmp; return *__tmp; @@ -1465,6 +1481,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const_reference back() const _GLIBCXX_NOEXCEPT { + __glibcxx_requires_nonempty(); const_iterator __tmp = end(); --__tmp; return *__tmp; @@ -1548,6 +1565,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void pop_front() _GLIBCXX_NOEXCEPT { + __glibcxx_requires_nonempty(); if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_last - 1) { @@ -1570,6 +1588,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void pop_back() _GLIBCXX_NOEXCEPT { + __glibcxx_requires_nonempty(); if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_first) { @@ -1645,7 +1664,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ iterator insert(const_iterator __p, initializer_list<value_type> __l) - { return this->insert(__p, __l.begin(), __l.end()); } + { + auto __offset = __p - cbegin(); + _M_range_insert_aux(__p._M_const_cast(), __l.begin(), __l.end(), + std::random_access_iterator_tag()); + return begin() + __offset; + } #endif #if __cplusplus >= 201103L @@ -1783,6 +1807,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void swap(deque& __x) _GLIBCXX_NOEXCEPT { +#if __cplusplus >= 201103L + __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value + || _M_get_Tp_allocator() == __x._M_get_Tp_allocator()); +#endif _M_impl._M_swap_data(__x._M_impl); _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); @@ -1819,9 +1847,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { - typedef typename std::iterator_traits<_InputIterator>:: - iterator_category _IterCategory; - _M_range_initialize(__first, __last, _IterCategory()); + _M_range_initialize(__first, __last, + std::__iterator_category(__first)); } // called by the second initialize_dispatch above @@ -1884,11 +1911,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type) - { - typedef typename std::iterator_traits<_InputIterator>:: - iterator_category _IterCategory; - _M_assign_aux(__first, __last, _IterCategory()); - } + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } // called by the second assign_dispatch above template<typename _InputIterator> @@ -1908,7 +1931,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _ForwardIterator __mid = __first; std::advance(__mid, size()); std::copy(__first, __mid, begin()); - insert(end(), __mid, __last); + _M_range_insert_aux(end(), __mid, __last, + std::__iterator_category(__first)); } else _M_erase_at_end(std::copy(__first, __last, begin())); @@ -1922,7 +1946,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER if (__n > size()) { std::fill(begin(), end(), __val); - insert(end(), __n - size(), __val); + _M_fill_insert(end(), __n - size(), __val); } else { @@ -1970,9 +1994,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _InputIterator __first, _InputIterator __last, __false_type) { - typedef typename std::iterator_traits<_InputIterator>:: - iterator_category _IterCategory; - _M_range_insert_aux(__pos, __first, __last, _IterCategory()); + _M_range_insert_aux(__pos, __first, __last, + std::__iterator_category(__first)); } // called by the second insert_dispatch above @@ -2196,8 +2219,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { // The rvalue's allocator cannot be moved and is not equal, // so we need to individually move each element. - this->assign(std::__make_move_if_noexcept_iterator(__x.begin()), - std::__make_move_if_noexcept_iterator(__x.end())); + _M_assign_aux(std::__make_move_if_noexcept_iterator(__x.begin()), + std::__make_move_if_noexcept_iterator(__x.end()), + std::random_access_iterator_tag()); __x.clear(); } } diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index 37ee5cc4053..5ff160ac6d1 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -341,8 +341,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void swap(pair& __p) - noexcept(__is_nothrow_swappable<_T1>::value - && __is_nothrow_swappable<_T2>::value) + noexcept(__and_<__is_nothrow_swappable<_T1>, + __is_nothrow_swappable<_T2>>::value) { using std::swap; swap(first, __p.first); @@ -399,11 +399,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Note: no std::swap overloads in C++03 mode, this has performance // implications, see, eg, libstdc++/38466. template<typename _T1, typename _T2> - inline void + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__and_<__is_swappable<_T1>, + __is_swappable<_T2>>::value>::type +#else + void +#endif swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } -#endif +#endif // __cplusplus >= 201103L /** * @brief A convenience wrapper for creating a pair from two objects. diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h index a292309dbf6..da984ff255e 100644 --- a/libstdc++-v3/include/bits/stl_queue.h +++ b/libstdc++-v3/include/bits/stl_queue.h @@ -274,12 +274,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L void swap(queue& __q) +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + noexcept(__is_nothrow_swappable<_Sequence>::value) +#else noexcept(__is_nothrow_swappable<_Tp>::value) +#endif { using std::swap; swap(c, __q.c); } -#endif +#endif // __cplusplus >= 201103L }; /** @@ -342,7 +346,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L template<typename _Tp, typename _Seq> - inline void + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__is_swappable<_Seq>::value>::type +#else + void +#endif swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } @@ -350,7 +360,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp, typename _Seq, typename _Alloc> struct uses_allocator<queue<_Tp, _Seq>, _Alloc> : public uses_allocator<_Seq, _Alloc>::type { }; -#endif +#endif // __cplusplus >= 201103L /** * @brief A standard container automatically sorting its contents. @@ -603,21 +613,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L void swap(priority_queue& __pq) - noexcept(__is_nothrow_swappable<_Tp>::value - && __is_nothrow_swappable<_Compare>::value) + noexcept(__and_< +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + __is_nothrow_swappable<_Sequence>, +#else + __is_nothrow_swappable<_Tp>, +#endif + __is_nothrow_swappable<_Compare> + >::value) { using std::swap; swap(c, __pq.c); swap(comp, __pq.comp); } -#endif +#endif // __cplusplus >= 201103L }; // No equality/comparison operators are provided for priority_queue. #if __cplusplus >= 201103L template<typename _Tp, typename _Sequence, typename _Compare> - inline void + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__and_<__is_swappable<_Sequence>, + __is_swappable<_Compare>>::value>::type +#else + void +#endif swap(priority_queue<_Tp, _Sequence, _Compare>& __x, priority_queue<_Tp, _Sequence, _Compare>& __y) noexcept(noexcept(__x.swap(__y))) @@ -627,7 +650,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename _Alloc> struct uses_allocator<priority_queue<_Tp, _Sequence, _Compare>, _Alloc> : public uses_allocator<_Sequence, _Alloc>::type { }; -#endif +#endif // __cplusplus >= 201103L _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/bits/stl_stack.h b/libstdc++-v3/include/bits/stl_stack.h index ea1d149b56c..612913da935 100644 --- a/libstdc++-v3/include/bits/stl_stack.h +++ b/libstdc++-v3/include/bits/stl_stack.h @@ -250,12 +250,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L void swap(stack& __s) +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + noexcept(__is_nothrow_swappable<_Sequence>::value) +#else noexcept(__is_nothrow_swappable<_Tp>::value) +#endif { using std::swap; swap(c, __s.c); } -#endif +#endif // __cplusplus >= 201103L }; /** @@ -319,7 +323,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L template<typename _Tp, typename _Seq> - inline void + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__is_swappable<_Seq>::value>::type +#else + void +#endif swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } @@ -327,7 +337,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp, typename _Seq, typename _Alloc> struct uses_allocator<stack<_Tp, _Seq>, _Alloc> : public uses_allocator<_Seq, _Alloc>::type { }; -#endif +#endif // __cplusplus >= 201103L _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 9b6d258f6ca..eaafa223dbf 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -63,6 +63,8 @@ #include <initializer_list> #endif +#include <debug/assertions.h> + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_CONTAINER @@ -72,7 +74,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER struct _Vector_base { typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template - rebind<_Tp>::other _Tp_alloc_type; + rebind<_Tp>::other _Tp_alloc_type; typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer pointer; @@ -214,30 +216,30 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER class vector : protected _Vector_base<_Tp, _Alloc> { // Concept requirements. - typedef typename _Alloc::value_type _Alloc_value_type; + typedef typename _Alloc::value_type _Alloc_value_type; #if __cplusplus < 201103L __glibcxx_class_requires(_Tp, _SGIAssignableConcept) #endif __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) - typedef _Vector_base<_Tp, _Alloc> _Base; - typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; - typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; + typedef _Vector_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; public: - typedef _Tp value_type; - typedef typename _Base::pointer pointer; - typedef typename _Alloc_traits::const_pointer const_pointer; - typedef typename _Alloc_traits::reference reference; - typedef typename _Alloc_traits::const_reference const_reference; + typedef _Tp value_type; + typedef typename _Base::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator; typedef __gnu_cxx::__normal_iterator<const_pointer, vector> const_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Alloc allocator_type; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; protected: using _Base::_M_allocate; @@ -319,8 +321,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ vector(const vector& __x) : _Base(__x.size(), - _Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator())) - { this->_M_impl._M_finish = + _Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator())) + { + this->_M_impl._M_finish = std::__uninitialized_copy_a(__x.begin(), __x.end(), this->_M_impl._M_start, _M_get_Tp_allocator()); @@ -340,7 +343,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /// Copy constructor with alternative allocator vector(const vector& __x, const allocator_type& __a) : _Base(__x.size(), __a) - { this->_M_impl._M_finish = + { + this->_M_impl._M_finish = std::__uninitialized_copy_a(__x.begin(), __x.end(), this->_M_impl._M_start, _M_get_Tp_allocator()); @@ -400,16 +404,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> - vector(_InputIterator __first, _InputIterator __last, + vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) - { _M_initialize_dispatch(__first, __last, __false_type()); } + { _M_initialize_dispatch(__first, __last, __false_type()); } #else template<typename _InputIterator> - vector(_InputIterator __first, _InputIterator __last, + vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) - { + { // Check whether it's an integral type. If so, it's not an iterator. typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_initialize_dispatch(__first, __last, _Integral()); @@ -449,10 +453,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER vector& operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) { - constexpr bool __move_storage = - _Alloc_traits::_S_propagate_on_move_assign() - || _Alloc_traits::_S_always_equal(); - _M_move_assign(std::move(__x), __bool_constant<__move_storage>()); + constexpr bool __move_storage = + _Alloc_traits::_S_propagate_on_move_assign() + || _Alloc_traits::_S_always_equal(); + _M_move_assign(std::move(__x), __bool_constant<__move_storage>()); return *this; } @@ -470,7 +474,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER vector& operator=(initializer_list<value_type> __l) { - this->assign(__l.begin(), __l.end()); + this->_M_assign_aux(__l.begin(), __l.end(), + random_access_iterator_tag()); return *this; } #endif @@ -504,14 +509,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> - void - assign(_InputIterator __first, _InputIterator __last) - { _M_assign_dispatch(__first, __last, __false_type()); } + void + assign(_InputIterator __first, _InputIterator __last) + { _M_assign_dispatch(__first, __last, __false_type()); } #else template<typename _InputIterator> - void - assign(_InputIterator __first, _InputIterator __last) - { + void + assign(_InputIterator __first, _InputIterator __last) + { // Check whether it's an integral type. If so, it's not an iterator. typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_assign_dispatch(__first, __last, _Integral()); @@ -532,7 +537,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ void assign(initializer_list<value_type> __l) - { this->assign(__l.begin(), __l.end()); } + { + this->_M_assign_aux(__l.begin(), __l.end(), + random_access_iterator_tag()); + } #endif /// Get a copy of the memory allocation object. @@ -694,7 +702,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER resize(size_type __new_size, const value_type& __x) { if (__new_size > size()) - insert(end(), __new_size - size(), __x); + _M_fill_insert(end(), __new_size - size(), __x); else if (__new_size < size()) _M_erase_at_end(this->_M_impl._M_start + __new_size); } @@ -714,7 +722,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER resize(size_type __new_size, value_type __x = value_type()) { if (__new_size > size()) - insert(end(), __new_size - size(), __x); + _M_fill_insert(end(), __new_size - size(), __x); else if (__new_size < size()) _M_erase_at_end(this->_M_impl._M_start + __new_size); } @@ -778,7 +786,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ reference operator[](size_type __n) _GLIBCXX_NOEXCEPT - { return *(this->_M_impl._M_start + __n); } + { + __glibcxx_requires_subscript(__n); + return *(this->_M_impl._M_start + __n); + } /** * @brief Subscript access to the data contained in the %vector. @@ -793,7 +804,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ const_reference operator[](size_type __n) const _GLIBCXX_NOEXCEPT - { return *(this->_M_impl._M_start + __n); } + { + __glibcxx_requires_subscript(__n); + return *(this->_M_impl._M_start + __n); + } protected: /// Safety check used only from at(). @@ -850,7 +864,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ reference front() _GLIBCXX_NOEXCEPT - { return *begin(); } + { + __glibcxx_requires_nonempty(); + return *begin(); + } /** * Returns a read-only (constant) reference to the data at the first @@ -858,7 +875,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ const_reference front() const _GLIBCXX_NOEXCEPT - { return *begin(); } + { + __glibcxx_requires_nonempty(); + return *begin(); + } /** * Returns a read/write reference to the data at the last @@ -866,7 +886,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ reference back() _GLIBCXX_NOEXCEPT - { return *(end() - 1); } + { + __glibcxx_requires_nonempty(); + return *(end() - 1); + } /** * Returns a read-only (constant) reference to the data at the @@ -874,7 +897,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ const_reference back() const _GLIBCXX_NOEXCEPT - { return *(end() - 1); } + { + __glibcxx_requires_nonempty(); + return *(end() - 1); + } // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 464. Suggestion for new member functions in standard containers. @@ -916,7 +942,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) { _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, - __x); + __x); ++this->_M_impl._M_finish; } else @@ -933,8 +959,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { emplace_back(std::move(__x)); } template<typename... _Args> - void - emplace_back(_Args&&... __args); + void + emplace_back(_Args&&... __args); #endif /** @@ -949,6 +975,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void pop_back() _GLIBCXX_NOEXCEPT { + __glibcxx_requires_nonempty(); --this->_M_impl._M_finish; _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish); } @@ -967,8 +994,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * std::list. */ template<typename... _Args> - iterator - emplace(const_iterator __position, _Args&&... __args); + iterator + emplace(const_iterator __position, _Args&&... __args); /** * @brief Inserts given value into %vector before specified iterator. @@ -1030,7 +1057,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ iterator insert(const_iterator __position, initializer_list<value_type> __l) - { return this->insert(__position, __l.begin(), __l.end()); } + { + auto __offset = __position - cbegin(); + _M_range_insert(begin() + __offset, __l.begin(), __l.end(), + std::random_access_iterator_tag()); + return begin() + __offset; + } #endif #if __cplusplus >= 201103L @@ -1092,10 +1124,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> - iterator - insert(const_iterator __position, _InputIterator __first, + iterator + insert(const_iterator __position, _InputIterator __first, _InputIterator __last) - { + { difference_type __offset = __position - cbegin(); _M_insert_dispatch(begin() + __offset, __first, __last, __false_type()); @@ -1117,10 +1149,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * consider using std::list. */ template<typename _InputIterator> - void - insert(iterator __position, _InputIterator __first, + void + insert(iterator __position, _InputIterator __first, _InputIterator __last) - { + { // Check whether it's an integral type. If so, it's not an iterator. typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_insert_dispatch(__position, __first, __last, _Integral()); @@ -1194,9 +1226,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void swap(vector& __x) _GLIBCXX_NOEXCEPT { +#if __cplusplus >= 201103L + __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value + || _M_get_Tp_allocator() == __x._M_get_Tp_allocator()); +#endif this->_M_impl._M_swap_data(__x._M_impl); _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), - __x._M_get_Tp_allocator()); + __x._M_get_Tp_allocator()); } /** @@ -1215,10 +1251,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * obtain @a n bytes of memory, and then copies [first,last) into it. */ template<typename _ForwardIterator> - pointer - _M_allocate_and_copy(size_type __n, + pointer + _M_allocate_and_copy(size_type __n, _ForwardIterator __first, _ForwardIterator __last) - { + { pointer __result = this->_M_allocate(__n); __try { @@ -1241,9 +1277,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 438. Ambiguity in the "do the right thing" clause template<typename _Integer> - void - _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type) - { + void + _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type) + { this->_M_impl._M_start = _M_allocate(static_cast<size_type>(__n)); this->_M_impl._M_end_of_storage = this->_M_impl._M_start + static_cast<size_type>(__n); @@ -1252,10 +1288,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the range constructor to implement [23.1.1]/9 template<typename _InputIterator> - void - _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, __false_type) - { + { typedef typename std::iterator_traits<_InputIterator>:: iterator_category _IterCategory; _M_range_initialize(__first, __last, _IterCategory()); @@ -1263,10 +1299,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the second initialize_dispatch above template<typename _InputIterator> - void - _M_range_initialize(_InputIterator __first, + void + _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) - { + { for (; __first != __last; ++__first) #if __cplusplus >= 201103L emplace_back(*__first); @@ -1277,10 +1313,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the second initialize_dispatch above template<typename _ForwardIterator> - void - _M_range_initialize(_ForwardIterator __first, + void + _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) - { + { const size_type __n = std::distance(__first, __last); this->_M_impl._M_start = this->_M_allocate(__n); this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; @@ -1319,31 +1355,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 438. Ambiguity in the "do the right thing" clause template<typename _Integer> - void - _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { _M_fill_assign(__n, __val); } + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign(__n, __val); } // Called by the range assign to implement [23.1.1]/9 template<typename _InputIterator> - void - _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type) - { - typedef typename std::iterator_traits<_InputIterator>:: - iterator_category _IterCategory; - _M_assign_aux(__first, __last, _IterCategory()); - } + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } // Called by the second assign_dispatch above template<typename _InputIterator> - void - _M_assign_aux(_InputIterator __first, _InputIterator __last, + void + _M_assign_aux(_InputIterator __first, _InputIterator __last, std::input_iterator_tag); // Called by the second assign_dispatch above template<typename _ForwardIterator> - void - _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + void + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); // Called by assign(n,t), and the range assign when it turns out @@ -1351,7 +1383,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void _M_fill_assign(size_type __n, const value_type& __val); - // Internal insert functions follow. // Called by the range insert to implement [23.1.1]/9 @@ -1359,32 +1390,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 438. Ambiguity in the "do the right thing" clause template<typename _Integer> - void - _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, + void + _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, __true_type) - { _M_fill_insert(__pos, __n, __val); } + { _M_fill_insert(__pos, __n, __val); } // Called by the range insert to implement [23.1.1]/9 template<typename _InputIterator> - void - _M_insert_dispatch(iterator __pos, _InputIterator __first, + void + _M_insert_dispatch(iterator __pos, _InputIterator __first, _InputIterator __last, __false_type) - { - typedef typename std::iterator_traits<_InputIterator>:: - iterator_category _IterCategory; - _M_range_insert(__pos, __first, __last, _IterCategory()); + { + _M_range_insert(__pos, __first, __last, + std::__iterator_category(__first)); } // Called by the second insert_dispatch above template<typename _InputIterator> - void - _M_range_insert(iterator __pos, _InputIterator __first, + void + _M_range_insert(iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag); // Called by the second insert_dispatch above template<typename _ForwardIterator> - void - _M_range_insert(iterator __pos, _ForwardIterator __first, + void + _M_range_insert(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); // Called by insert(p,n,x), and the range insert when it turns out to be @@ -1407,12 +1437,21 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_insert_aux(iterator __position, const value_type& __x); #else template<typename... _Args> - void - _M_insert_aux(iterator __position, _Args&&... __args); + static void + _S_insert_aux_assign(iterator __pos, _Args&&... __args) + { *__pos = _Tp(std::forward<_Args>(__args)...); } + + static void + _S_insert_aux_assign(iterator __pos, _Tp&& __arg) + { *__pos = std::move(__arg); } + + template<typename... _Args> + void + _M_insert_aux(iterator __position, _Args&&... __args); template<typename... _Args> - void - _M_emplace_back_aux(_Args&&... __args); + void + _M_emplace_back_aux(_Args&&... __args); #endif // Called by the latter. diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index db31b54a432..15ef8a89475 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -635,7 +635,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template<typename _Tp, typename _Dp> - inline void + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__is_swappable<_Dp>::value>::type +#else + void +#endif swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) noexcept { __x.swap(__y); } diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index 715b83eb679..9cb546403aa 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -256,7 +256,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER if (__first == __last) _M_erase_at_end(__cur); else - insert(end(), __first, __last); + _M_range_insert(end(), __first, __last, + std::__iterator_category(__first)); } template<typename _Tp, typename _Alloc> @@ -342,7 +343,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus < 201103L *__position = __x_copy; #else - *__position = _Tp(std::forward<_Args>(__args)...); + _S_insert_aux_assign(__position, std::forward<_Args>(__args)...); #endif } else diff --git a/libstdc++-v3/include/debug/array b/libstdc++-v3/include/debug/array index e12d25f6e76..6d51309694a 100644 --- a/libstdc++-v3/include/debug/array +++ b/libstdc++-v3/include/debug/array @@ -86,7 +86,7 @@ namespace __debug void swap(array& __other) - noexcept(__is_nothrow_swappable<_Tp>::value) + noexcept(_AT_Type::_Is_nothrow_swappable::value) { std::swap_ranges(begin(), end(), __other.begin()); } // Iterators. @@ -168,9 +168,8 @@ namespace __debug at(size_type __n) { if (__n >= _Nm) - std::__throw_out_of_range_fmt(__N("array::at: __n " - "(which is %zu) >= _Nm " - "(which is %zu)"), + std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) " + ">= _Nm (which is %zu)"), __n, _Nm); return _AT_Type::_S_ref(_M_elems, __n); } diff --git a/libstdc++-v3/include/debug/assertions.h b/libstdc++-v3/include/debug/assertions.h index 802645c620f..3708d129031 100644 --- a/libstdc++-v3/include/debug/assertions.h +++ b/libstdc++-v3/include/debug/assertions.h @@ -33,20 +33,36 @@ # define _GLIBCXX_DEBUG_ASSERT(_Condition) # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) -# define _GLIBCXX_DEBUG_ONLY(_Statement) ; +# define _GLIBCXX_DEBUG_ONLY(_Statement) -#else - -#define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition) +#endif -#ifdef _GLIBCXX_DEBUG_PEDANTIC -# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition) +#ifndef _GLIBCXX_ASSERTIONS +# define __glibcxx_requires_non_empty_range(_First,_Last) +# define __glibcxx_requires_nonempty() +# define __glibcxx_requires_subscript(_N) #else -# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) + +// Verify that [_First, _Last) forms a non-empty iterator range. +# define __glibcxx_requires_non_empty_range(_First,_Last) \ + __glibcxx_assert(__builtin_expect(_First != _Last, true)) +# define __glibcxx_requires_subscript(_N) \ + __glibcxx_assert(__builtin_expect(_N < this->size(), true)) +// Verify that the container is nonempty +# define __glibcxx_requires_nonempty() \ + __glibcxx_assert(__builtin_expect(!this->empty(), true)) #endif -# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement +#ifdef _GLIBCXX_DEBUG +# define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition) +# ifdef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition) +# else +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) +# endif + +# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement #endif #endif // _GLIBCXX_DEBUG_ASSERTIONS diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h index 3d46b6d81b4..79fe00d7c76 100644 --- a/libstdc++-v3/include/debug/debug.h +++ b/libstdc++-v3/include/debug/debug.h @@ -74,24 +74,11 @@ namespace __gnu_debug # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) # define __glibcxx_requires_string(_String) # define __glibcxx_requires_string_len(_String,_Len) -# define __glibcxx_requires_subscript(_N) # define __glibcxx_requires_irreflexive(_First,_Last) # define __glibcxx_requires_irreflexive2(_First,_Last) # define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred) # define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred) -#ifdef _GLIBCXX_ASSERTIONS -// Verify that [_First, _Last) forms a non-empty iterator range. -# define __glibcxx_requires_non_empty_range(_First,_Last) \ - __glibcxx_assert(_First != _Last) -// Verify that the container is nonempty -# define __glibcxx_requires_nonempty() \ - __glibcxx_assert(! this->empty()) -#else -# define __glibcxx_requires_non_empty_range(_First,_Last) -# define __glibcxx_requires_nonempty() -#endif - #else # include <debug/macros.h> @@ -99,8 +86,6 @@ namespace __gnu_debug # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) # define __glibcxx_requires_valid_range(_First,_Last) \ __glibcxx_check_valid_range(_First,_Last) -# define __glibcxx_requires_non_empty_range(_First,_Last) \ - __glibcxx_check_non_empty_range(_First,_Last) # define __glibcxx_requires_sorted(_First,_Last) \ __glibcxx_check_sorted(_First,_Last) # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \ @@ -121,11 +106,9 @@ namespace __gnu_debug __glibcxx_check_heap(_First,_Last) # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ __glibcxx_check_heap_pred(_First,_Last,_Pred) -# define __glibcxx_requires_nonempty() __glibcxx_check_nonempty() # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String) # define __glibcxx_requires_string_len(_String,_Len) \ __glibcxx_check_string_len(_String,_Len) -# define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N) # define __glibcxx_requires_irreflexive(_First,_Last) \ __glibcxx_check_irreflexive(_First,_Last) # define __glibcxx_requires_irreflexive2(_First,_Last) \ diff --git a/libstdc++-v3/include/debug/helper_functions.h b/libstdc++-v3/include/debug/helper_functions.h index 5ee33e8a3b7..f1a74eb495a 100644 --- a/libstdc++-v3/include/debug/helper_functions.h +++ b/libstdc++-v3/include/debug/helper_functions.h @@ -138,6 +138,7 @@ namespace __gnu_debug return __dist.first >= 0; } + // Can't tell so assume it is fine. return true; } diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array index c45a599a279..73d26698f72 100644 --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -48,6 +48,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER struct __array_traits { typedef _Tp _Type[_Nm]; + typedef __is_swappable<_Tp> _Is_swappable; + typedef __is_nothrow_swappable<_Tp> _Is_nothrow_swappable; static constexpr _Tp& _S_ref(const _Type& __t, std::size_t __n) noexcept @@ -62,6 +64,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER struct __array_traits<_Tp, 0> { struct _Type { }; + typedef true_type _Is_swappable; + typedef true_type _Is_nothrow_swappable; static constexpr _Tp& _S_ref(const _Type&, std::size_t) noexcept @@ -114,7 +118,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void swap(array& __other) - noexcept(__is_nothrow_swappable<_Tp>::value) + noexcept(_AT_Type::_Is_nothrow_swappable::value) { std::swap_ranges(begin(), end(), __other.begin()); } // Iterators. @@ -134,19 +138,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER end() const noexcept { return const_iterator(data() + _Nm); } - reverse_iterator + reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - const_reverse_iterator + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - reverse_iterator + reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - const_reverse_iterator + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } @@ -158,22 +162,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER cend() const noexcept { return const_iterator(data() + _Nm); } - const_reverse_iterator + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } - const_reverse_iterator + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } // Capacity. - constexpr size_type + constexpr size_type size() const noexcept { return _Nm; } - constexpr size_type + constexpr size_type max_size() const noexcept { return _Nm; } - constexpr bool + constexpr bool empty() const noexcept { return size() == 0; } // Element access. @@ -207,22 +211,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _AT_Type::_S_ref(_M_elems, 0)); } - reference + reference front() noexcept { return *begin(); } - constexpr const_reference + constexpr const_reference front() const noexcept { return _AT_Type::_S_ref(_M_elems, 0); } - reference + reference back() noexcept { return _Nm ? *(end() - 1) : *end(); } - constexpr const_reference + constexpr const_reference back() const noexcept - { - return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) + { + return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) : _AT_Type::_S_ref(_M_elems, 0); } @@ -237,7 +241,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Array comparisons. template<typename _Tp, std::size_t _Nm> - inline bool + inline bool operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return std::equal(__one.begin(), __one.end(), __two.begin()); } @@ -249,9 +253,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, std::size_t _Nm> inline bool operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) - { + { return std::lexicographical_compare(__a.begin(), __a.end(), - __b.begin(), __b.end()); + __b.begin(), __b.end()); } template<typename _Tp, std::size_t _Nm> @@ -271,7 +275,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Specialized algorithms. template<typename _Tp, std::size_t _Nm> - inline void + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if< + _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value + >::type +#else + void +#endif swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) noexcept(noexcept(__one.swap(__two))) { __one.swap(__two); } @@ -312,7 +324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Tuple interface to class template array. /// tuple_size - template<typename _Tp> + template<typename _Tp> class tuple_size; /// Partial specialization for std::array diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index 3c8ece85b0b..8cbc91f9347 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -198,11 +198,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return load(); } _Tp - operator=(_Tp __i) noexcept + operator=(_Tp __i) noexcept { store(__i); return __i; } _Tp - operator=(_Tp __i) volatile noexcept + operator=(_Tp __i) volatile noexcept { store(__i); return __i; } bool @@ -231,7 +231,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp load(memory_order __m = memory_order_seq_cst) const noexcept - { + { _Tp tmp; __atomic_load(std::__addressof(_M_i), std::__addressof(tmp), __m); return tmp; @@ -239,7 +239,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp load(memory_order __m = memory_order_seq_cst) const volatile noexcept - { + { _Tp tmp; __atomic_load(std::__addressof(_M_i), std::__addressof(tmp), __m); return tmp; @@ -247,7 +247,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp exchange(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept - { + { _Tp tmp; __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), std::__addressof(tmp), __m); @@ -255,9 +255,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } _Tp - exchange(_Tp __i, + exchange(_Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept - { + { _Tp tmp; __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), std::__addressof(tmp), __m); @@ -265,7 +265,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } bool - compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, + compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) noexcept { return __atomic_compare_exchange(std::__addressof(_M_i), @@ -275,7 +275,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } bool - compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, + compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) volatile noexcept { return __atomic_compare_exchange(std::__addressof(_M_i), @@ -297,7 +297,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __cmpexch_failure_order(__m)); } bool - compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, + compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) noexcept { return __atomic_compare_exchange(std::__addressof(_M_i), @@ -307,7 +307,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } bool - compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, + compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) volatile noexcept { return __atomic_compare_exchange(std::__addressof(_M_i), diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset index 2ad88605128..0156d1f4d61 100644 --- a/libstdc++-v3/include/std/bitset +++ b/libstdc++-v3/include/std/bitset @@ -245,7 +245,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_w[__n] = _M_w[__n - __wshift]; else { - const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD + const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD - __offset); for (size_t __n = _Nw - 1; __n > __wshift; --__n) _M_w[__n] = ((_M_w[__n - __wshift] << __offset) @@ -279,7 +279,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER | (_M_w[__n + __wshift + 1] << __sub_offset)); _M_w[__limit] = _M_w[_Nw-1] >> __offset; } - + std::fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0)); } } @@ -556,7 +556,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _WordT& _M_getword(size_t) _GLIBCXX_NOEXCEPT { - __throw_out_of_range(__N("_Base_bitset::_M_getword")); + __throw_out_of_range(__N("_Base_bitset::_M_getword")); return *new _WordT; } @@ -659,7 +659,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER typedef unsigned long _WordT; static void - _S_do_sanitize(_WordT) _GLIBCXX_NOEXCEPT { } + _S_do_sanitize(_WordT) _GLIBCXX_NOEXCEPT { } }; #if __cplusplus >= 201103L @@ -773,7 +773,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void _M_do_sanitize() _GLIBCXX_NOEXCEPT - { + { typedef _Sanitize<_Nb % _GLIBCXX_BITSET_BITS_PER_WORD> __sanitize_type; __sanitize_type::_S_do_sanitize(this->_M_hiword()); } @@ -801,10 +801,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _WordT* _M_wp; size_t _M_bpos; - + // left undefined reference(); - + public: reference(bitset& __b, size_t __pos) _GLIBCXX_NOEXCEPT { @@ -981,7 +981,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } //@} - + //@{ /** * Operations on bitsets. @@ -1015,7 +1015,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } //@} - + //@{ /** * These versions of single-bit set, reset, flip, and test are @@ -1058,7 +1058,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos)) != static_cast<_WordT>(0)); } //@} - + // Set, reset, and flip. /** * @brief Sets every bit to true. @@ -1107,7 +1107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER this->_M_check(__position, __N("bitset::reset")); return _Unchecked_reset(__position); } - + /** * @brief Toggles every bit to its opposite value. */ @@ -1130,7 +1130,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER this->_M_check(__position, __N("bitset::flip")); return _Unchecked_flip(__position); } - + /// See the no-argument flip(). bitset<_Nb> operator~() const _GLIBCXX_NOEXCEPT @@ -1159,7 +1159,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER operator[](size_t __position) const { return _Unchecked_test(__position); } //@} - + /** * @brief Returns a numerical interpretation of the %bitset. * @return The integral equivalent of the bits. @@ -1302,7 +1302,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT { return !this->_M_is_equal(__rhs); } //@} - + /** * @brief Tests the value of a bit. * @param __position The index of a bit. @@ -1352,7 +1352,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER operator>>(size_t __position) const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(*this) >>= __position; } //@} - + /** * @brief Finds the index of the first "on" bit. * @return The index of the first bit set, or size() if not found. @@ -1482,7 +1482,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER for (size_t __i = _Nb; __i > 0; --__i) { static typename _Traits::int_type __eof = _Traits::eof(); - + typename _Traits::int_type __c1 = __is.rdbuf()->sbumpc(); if (_Traits::eq_int_type(__c1, __eof)) { @@ -1508,7 +1508,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } __catch(__cxxabiv1::__forced_unwind&) { - __is._M_setstate(__ios_base::badbit); + __is._M_setstate(__ios_base::badbit); __throw_exception_again; } __catch(...) diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index ba492df5624..9104881eb93 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -72,7 +72,7 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION // 20.11.4.3 specialization of common_type (for duration, sfinae-friendly) - + template<typename _CT, typename _Period1, typename _Period2> struct __duration_common_type_wrapper { @@ -98,7 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; // 20.11.4.3 specialization of common_type (for time_point, sfinae-friendly) - + template<typename _CT, typename _Clock> struct __timepoint_common_type_wrapper { @@ -625,11 +625,11 @@ _GLIBCXX_END_NAMESPACE_VERSION typename common_type<duration<_Rep1, _Period1>, _Dur2>::type> operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Dur2>& __rhs) - { + { typedef duration<_Rep1, _Period1> __dur1; typedef typename common_type<__dur1,_Dur2>::type __ct; typedef time_point<_Clock, __ct> __time_point; - return __time_point(__rhs.time_since_epoch() + __lhs); + return __time_point(__rhs.time_since_epoch() + __lhs); } template<typename _Clock, typename _Dur1, @@ -638,11 +638,11 @@ _GLIBCXX_END_NAMESPACE_VERSION typename common_type<_Dur1, duration<_Rep2, _Period2>>::type> operator-(const time_point<_Clock, _Dur1>& __lhs, const duration<_Rep2, _Period2>& __rhs) - { + { typedef duration<_Rep2, _Period2> __dur2; typedef typename common_type<_Dur1,__dur2>::type __ct; typedef time_point<_Clock, __ct> __time_point; - return __time_point(__lhs.time_since_epoch() -__rhs); + return __time_point(__lhs.time_since_epoch() -__rhs); } template<typename _Clock, typename _Dur1, typename _Dur2> @@ -688,9 +688,9 @@ _GLIBCXX_END_NAMESPACE_VERSION { return !(__lhs < __rhs); } - // Clocks. + // Clocks. - // Why nanosecond resolution as the default? + // Why nanosecond resolution as the default? // Why have std::system_clock always count in the higest // resolution (ie nanoseconds), even if on some OSes the low 3 // or 9 decimal digits will be always zero? This allows later diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 9b7c1d7279e..bb09b7d0aa7 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -93,7 +93,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Return @a x to the @a y'th power. template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const _Tp&); /// Return @a x to the @a y'th power. - template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, + template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const complex<_Tp>&); /// Return @a x to the @a y'th power. template<typename _Tp> complex<_Tp> pow(const _Tp&, const complex<_Tp>&); @@ -107,8 +107,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> complex<_Tp> tan(const complex<_Tp>&); /// Return complex hyperbolic tangent of @a z. template<typename _Tp> complex<_Tp> tanh(const complex<_Tp>&); - - + + // 26.2.2 Primary template class complex /** * Template to represent complex numbers. @@ -123,7 +123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { /// Value typedef. typedef _Tp value_type; - + /// Default constructor. First parameter is x, second parameter is y. /// Unspecified parameters default to 0. _GLIBCXX_CONSTEXPR complex(const _Tp& __r = _Tp(), const _Tp& __i = _Tp()) @@ -143,41 +143,41 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. _GLIBCXX_ABI_TAG_CXX11 - constexpr _Tp + constexpr _Tp real() const { return _M_real; } _GLIBCXX_ABI_TAG_CXX11 - constexpr _Tp + constexpr _Tp imag() const { return _M_imag; } #else /// Return real part of complex number. - _Tp& + _Tp& real() { return _M_real; } /// Return real part of complex number. - const _Tp& + const _Tp& real() const { return _M_real; } /// Return imaginary part of complex number. - _Tp& + _Tp& imag() { return _M_imag; } /// Return imaginary part of complex number. - const _Tp& + const _Tp& imag() const { return _M_imag; } #endif // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. - void + void real(_Tp __val) { _M_real = __val; } - void + void imag(_Tp __val) { _M_imag = __val; } /// Assign a scalar to this complex number. complex<_Tp>& operator=(const _Tp&); - + /// Add a scalar to this complex number. // 26.2.5/1 complex<_Tp>& @@ -237,7 +237,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_real = __t; _M_imag = _Tp(); return *this; - } + } // 26.2.5/5 template<typename _Tp> @@ -317,7 +317,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_real = __r / __n; return *this; } - + // Operators: //@{ /// Return new complex value @a x plus @a y. @@ -359,7 +359,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __r -= __y; return __r; } - + template<typename _Tp> inline complex<_Tp> operator-(const complex<_Tp>& __x, const _Tp& __y) @@ -419,7 +419,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __r /= __y; return __r; } - + template<typename _Tp> inline complex<_Tp> operator/(const complex<_Tp>& __x, const _Tp& __y) @@ -495,23 +495,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp __re_x, __im_x; _CharT __ch; __is >> __ch; - if (__ch == '(') + if (__ch == '(') { __is >> __re_x >> __ch; - if (__ch == ',') + if (__ch == ',') { __is >> __im_x >> __ch; - if (__ch == ')') + if (__ch == ')') __x = complex<_Tp>(__re_x, __im_x); else __is.setstate(ios_base::failbit); } - else if (__ch == ')') + else if (__ch == ')') __x = __re_x; else __is.setstate(ios_base::failbit); } - else + else { __is.putback(__ch); __is >> __re_x; @@ -549,17 +549,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline _Tp& real(complex<_Tp>& __z) { return __z.real(); } - + template<typename _Tp> inline const _Tp& real(const complex<_Tp>& __z) { return __z.real(); } - + template<typename _Tp> inline _Tp& imag(complex<_Tp>& __z) { return __z.imag(); } - + template<typename _Tp> inline const _Tp& imag(const complex<_Tp>& __z) @@ -576,7 +576,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const _Tp __s = std::max(abs(__x), abs(__y)); if (__s == _Tp()) // well ... return __s; - __x /= __s; + __x /= __s; __y /= __s; return __s * sqrt(__x * __x + __y * __y); } @@ -599,7 +599,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> inline _Tp abs(const complex<_Tp>& __z) { return __complex_abs(__z); } -#endif +#endif // 26.2.7/4: arg(__z): Returns the phase angle of __z. @@ -655,12 +655,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __res * __res; } }; - + template<typename _Tp> inline _Tp norm(const complex<_Tp>& __z) { - return _Norm_helper<__is_floating<_Tp>::__value + return _Norm_helper<__is_floating<_Tp>::__value && !_GLIBCXX_FAST_MATH>::_S_do_it(__z); } @@ -676,7 +676,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline complex<_Tp> conj(const complex<_Tp>& __z) { return complex<_Tp>(__z.real(), -__z.imag()); } - + // Transcendentals // 26.2.8/1 cos(__z): Returns the cosine of __z. @@ -804,7 +804,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); - return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y)); + return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y)); } #if _GLIBCXX_USE_C99_COMPLEX @@ -839,14 +839,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float - __complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); } + __complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); } inline __complex__ double - __complex_sinh(__complex__ double __z) { return __builtin_csinh(__z); } + __complex_sinh(__complex__ double __z) { return __builtin_csinh(__z); } inline __complex__ long double __complex_sinh(const __complex__ long double& __z) - { return __builtin_csinhl(__z); } + { return __builtin_csinhl(__z); } template<typename _Tp> inline complex<_Tp> @@ -902,7 +902,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // 26.2.8/14 tan(__z): Return the complex tangent of __z. - + template<typename _Tp> inline complex<_Tp> __complex_tan(const complex<_Tp>& __z) @@ -930,7 +930,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // 26.2.8/15 tanh(__z): Returns the hyperbolic tangent of __z. - + template<typename _Tp> inline complex<_Tp> __complex_tanh(const complex<_Tp>& __z) @@ -1066,38 +1066,38 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif explicit _GLIBCXX_CONSTEXPR complex(const complex<double>&); - explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&); + explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&); #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. __attribute ((__abi_tag__ ("cxx11"))) - constexpr float + constexpr float real() const { return __real__ _M_value; } __attribute ((__abi_tag__ ("cxx11"))) - constexpr float + constexpr float imag() const { return __imag__ _M_value; } #else - float& + float& real() { return __real__ _M_value; } - const float& - real() const { return __real__ _M_value; } + const float& + real() const { return __real__ _M_value; } - float& + float& imag() { return __imag__ _M_value; } - const float& + const float& imag() const { return __imag__ _M_value; } #endif // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. - void + void real(float __val) { __real__ _M_value = __val; } - void + void imag(float __val) { __imag__ _M_value = __val; } complex& @@ -1217,38 +1217,38 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_CONSTEXPR complex(const complex<float>& __z) : _M_value(__z.__rep()) { } - explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&); + explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&); #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. __attribute ((__abi_tag__ ("cxx11"))) - constexpr double + constexpr double real() const { return __real__ _M_value; } __attribute ((__abi_tag__ ("cxx11"))) - constexpr double + constexpr double imag() const { return __imag__ _M_value; } #else - double& + double& real() { return __real__ _M_value; } - const double& + const double& real() const { return __real__ _M_value; } - double& + double& imag() { return __imag__ _M_value; } - const double& + const double& imag() const { return __imag__ _M_value; } #endif // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. - void + void real(double __val) { __real__ _M_value = __val; } - void + void imag(double __val) { __imag__ _M_value = __val; } complex& @@ -1264,7 +1264,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_value += __d; return *this; } - + complex& operator-=(double __d) { @@ -1354,7 +1354,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { } - _GLIBCXX_CONSTEXPR complex(long double __r = 0.0L, + _GLIBCXX_CONSTEXPR complex(long double __r = 0.0L, long double __i = 0.0L) #if __cplusplus >= 201103L : _M_value{ __r, __i } { } @@ -1375,32 +1375,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. __attribute ((__abi_tag__ ("cxx11"))) - constexpr long double + constexpr long double real() const { return __real__ _M_value; } __attribute ((__abi_tag__ ("cxx11"))) - constexpr long double + constexpr long double imag() const { return __imag__ _M_value; } #else - long double& + long double& real() { return __real__ _M_value; } - const long double& + const long double& real() const { return __real__ _M_value; } - long double& + long double& imag() { return __imag__ _M_value; } - const long double& + const long double& imag() const { return __imag__ _M_value; } #endif // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. - void + void real(long double __val) { __real__ _M_value = __val; } - void + void imag(long double __val) { __imag__ _M_value = __val; } complex& @@ -1554,7 +1554,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public: typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type; }; - + template<typename _Tp, typename _Up> struct __promote_2<std::complex<_Tp>, std::complex<_Up> > { @@ -1653,7 +1653,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION asin(const std::complex<_Tp>& __z) { return __complex_asin(__z); } #endif - + template<typename _Tp> std::complex<_Tp> __complex_atan(const std::complex<_Tp>& __z) diff --git a/libstdc++-v3/include/std/condition_variable b/libstdc++-v3/include/std/condition_variable index 62a7ee14519..2e975e890ff 100644 --- a/libstdc++-v3/include/std/condition_variable +++ b/libstdc++-v3/include/std/condition_variable @@ -60,7 +60,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// cv_status enum class cv_status { no_timeout, timeout }; - + /// condition_variable class condition_variable { @@ -250,7 +250,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION unique_lock<mutex> __my_lock2(std::move(__my_lock)); _M_cond.wait(__my_lock2); } - + template<typename _Lock, typename _Predicate> void diff --git a/libstdc++-v3/include/std/fstream b/libstdc++-v3/include/std/fstream index 08b496594f9..b0d03edc092 100644 --- a/libstdc++-v3/include/std/fstream +++ b/libstdc++-v3/include/std/fstream @@ -386,7 +386,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Common code for seekoff, seekpos, and overflow pos_type _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state); - + int _M_get_ext_pos(__state_type &__state); diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 1edd8868cfc..0fdf0436694 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -1906,7 +1906,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) * type @c T1, @c T2, ..., @c TN and returns a value convertible * to @c Res. * - * The newly-created %function object will target a copy of + * The newly-created %function object will target a copy of * @a __f. If @a __f is @c reference_wrapper<F>, then this function * object will contain a reference to the function object @c * __f.get(). If @a __f is a NULL function pointer or NULL diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index 80b7b06a45f..aa866c5906a 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -225,7 +225,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef _Res result_type; _Result() noexcept : _M_initialized() { } - + ~_Result() { if (_M_initialized) @@ -263,7 +263,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit _Result_alloc(const _Alloc& __a) : _Result<_Res>(), _Alloc(__a) { } - + private: void _M_destroy() { diff --git a/libstdc++-v3/include/std/iomanip b/libstdc++-v3/include/std/iomanip index 45d0f90a808..cb0df866695 100644 --- a/libstdc++-v3/include/std/iomanip +++ b/libstdc++-v3/include/std/iomanip @@ -62,24 +62,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Sent to a stream object, this manipulator resets the specified flags, * via @e stream.setf(0,__mask). */ - inline _Resetiosflags + inline _Resetiosflags resetiosflags(ios_base::fmtflags __mask) { return { __mask }; } template<typename _CharT, typename _Traits> - inline basic_istream<_CharT, _Traits>& + inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f) - { - __is.setf(ios_base::fmtflags(0), __f._M_mask); - return __is; + { + __is.setf(ios_base::fmtflags(0), __f._M_mask); + return __is; } template<typename _CharT, typename _Traits> - inline basic_ostream<_CharT, _Traits>& + inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f) - { - __os.setf(ios_base::fmtflags(0), __f._M_mask); - return __os; + { + __os.setf(ios_base::fmtflags(0), __f._M_mask); + return __os; } @@ -92,24 +92,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Sent to a stream object, this manipulator sets the format flags * to @a __mask. */ - inline _Setiosflags + inline _Setiosflags setiosflags(ios_base::fmtflags __mask) { return { __mask }; } template<typename _CharT, typename _Traits> - inline basic_istream<_CharT, _Traits>& + inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f) - { - __is.setf(__f._M_mask); - return __is; + { + __is.setf(__f._M_mask); + return __is; } template<typename _CharT, typename _Traits> - inline basic_ostream<_CharT, _Traits>& + inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f) - { - __os.setf(__f._M_mask); - return __os; + { + __os.setf(__f._M_mask); + return __os; } @@ -123,32 +123,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base * is 8, 10, or 16, accordingly, and to 0 if @a __base is any other value. */ - inline _Setbase + inline _Setbase setbase(int __base) { return { __base }; } template<typename _CharT, typename _Traits> - inline basic_istream<_CharT, _Traits>& + inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f) { - __is.setf(__f._M_base == 8 ? ios_base::oct : - __f._M_base == 10 ? ios_base::dec : - __f._M_base == 16 ? ios_base::hex : + __is.setf(__f._M_base == 8 ? ios_base::oct : + __f._M_base == 10 ? ios_base::dec : + __f._M_base == 16 ? ios_base::hex : ios_base::fmtflags(0), ios_base::basefield); - return __is; + return __is; } - + template<typename _CharT, typename _Traits> - inline basic_ostream<_CharT, _Traits>& + inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f) { - __os.setf(__f._M_base == 8 ? ios_base::oct : - __f._M_base == 10 ? ios_base::dec : - __f._M_base == 16 ? ios_base::hex : + __os.setf(__f._M_base == 8 ? ios_base::oct : + __f._M_base == 10 ? ios_base::dec : + __f._M_base == 16 ? ios_base::hex : ios_base::fmtflags(0), ios_base::basefield); - return __os; + return __os; } - + template<typename _CharT> struct _Setfill { _CharT _M_c; }; @@ -166,19 +166,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return { __c }; } template<typename _CharT, typename _Traits> - inline basic_istream<_CharT, _Traits>& + inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f) - { - __is.fill(__f._M_c); - return __is; + { + __is.fill(__f._M_c); + return __is; } template<typename _CharT, typename _Traits> - inline basic_ostream<_CharT, _Traits>& + inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f) - { - __os.fill(__f._M_c); - return __os; + { + __os.fill(__f._M_c); + return __os; } @@ -191,24 +191,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Sent to a stream object, this manipulator calls @c precision(__n) for * that object. */ - inline _Setprecision + inline _Setprecision setprecision(int __n) { return { __n }; } template<typename _CharT, typename _Traits> - inline basic_istream<_CharT, _Traits>& + inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f) - { - __is.precision(__f._M_n); - return __is; + { + __is.precision(__f._M_n); + return __is; } template<typename _CharT, typename _Traits> - inline basic_ostream<_CharT, _Traits>& + inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f) - { - __os.precision(__f._M_n); - return __os; + { + __os.precision(__f._M_n); + return __os; } @@ -221,35 +221,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Sent to a stream object, this manipulator calls @c width(__n) for * that object. */ - inline _Setw + inline _Setw setw(int __n) { return { __n }; } template<typename _CharT, typename _Traits> - inline basic_istream<_CharT, _Traits>& + inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f) { __is.width(__f._M_n); - return __is; + return __is; } template<typename _CharT, typename _Traits> - inline basic_ostream<_CharT, _Traits>& + inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f) { __os.width(__f._M_n); - return __os; + return __os; } #if __cplusplus >= 201103L - + template<typename _MoneyT> struct _Get_money { _MoneyT& _M_mon; bool _M_intl; }; /** * @brief Extended manipulator for extracting money. * @param __mon Either long double or a specialization of @c basic_string. - * @param __intl A bool indicating whether international format + * @param __intl A bool indicating whether international format * is to be used. * * Sent to a stream object, this manipulator extracts @a __mon. @@ -286,7 +286,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__err) __is.setstate(__err); } - return __is; + return __is; } @@ -296,7 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @brief Extended manipulator for inserting money. * @param __mon Either long double or a specialization of @c basic_string. - * @param __intl A bool indicating whether international format + * @param __intl A bool indicating whether international format * is to be used. * * Sent to a stream object, this manipulator inserts @a __mon. @@ -307,7 +307,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return { __mon, __intl }; } template<typename _CharT, typename _Traits, typename _MoneyT> - basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_money<_MoneyT> __f) { typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os); @@ -334,7 +334,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__err) __os.setstate(__err); } - return __os; + return __os; } template<typename _CharT> @@ -490,7 +490,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // __cplusplus >= 201103L // Inhibit implicit instantiations for required instantiations, - // which are defined via explicit instantiations elsewhere. + // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. #if _GLIBCXX_EXTERN_TEMPLATE extern template ostream& operator<<(ostream&, _Setfill<char>); diff --git a/libstdc++-v3/include/std/iosfwd b/libstdc++-v3/include/std/iosfwd index e01a464e686..d81782e63f3 100644 --- a/libstdc++-v3/include/std/iosfwd +++ b/libstdc++-v3/include/std/iosfwd @@ -129,7 +129,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 /// Base class for @c char streams. - typedef basic_ios<char> ios; + typedef basic_ios<char> ios; /// Base class for @c char buffers. typedef basic_streambuf<char> streambuf; diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream index f36d2b6c91e..d4cf7bcbfd5 100644 --- a/libstdc++-v3/include/std/istream +++ b/libstdc++-v3/include/std/istream @@ -922,7 +922,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _CharT, typename _Traits, typename _Tp> inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) - { + { __is >> __x; return __is; } diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits index 53a183f712e..a1224d61aa6 100644 --- a/libstdc++-v3/include/std/limits +++ b/libstdc++-v3/include/std/limits @@ -296,7 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /** See std::float_round_style for more information. This is only meaningful for floating types; integer types will all be round_toward_zero. */ - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -384,10 +384,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR bool + static _GLIBCXX_CONSTEXPR bool min() _GLIBCXX_USE_NOEXCEPT { return false; } - static _GLIBCXX_CONSTEXPR bool + static _GLIBCXX_CONSTEXPR bool max() _GLIBCXX_USE_NOEXCEPT { return true; } #if __cplusplus >= 201103L @@ -404,10 +404,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR bool + static _GLIBCXX_CONSTEXPR bool epsilon() _GLIBCXX_USE_NOEXCEPT { return false; } - static _GLIBCXX_CONSTEXPR bool + static _GLIBCXX_CONSTEXPR bool round_error() _GLIBCXX_USE_NOEXCEPT { return false; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -418,20 +418,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR bool + static _GLIBCXX_CONSTEXPR bool infinity() _GLIBCXX_USE_NOEXCEPT { return false; } - static _GLIBCXX_CONSTEXPR bool + static _GLIBCXX_CONSTEXPR bool quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return false; } - static _GLIBCXX_CONSTEXPR bool + static _GLIBCXX_CONSTEXPR bool signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return false; } - static _GLIBCXX_CONSTEXPR bool + static _GLIBCXX_CONSTEXPR bool denorm_min() _GLIBCXX_USE_NOEXCEPT { return false; } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; @@ -443,7 +443,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // promotion semantics. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -453,14 +453,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR char + static _GLIBCXX_CONSTEXPR char min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min(char); } - static _GLIBCXX_CONSTEXPR char + static _GLIBCXX_CONSTEXPR char max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max(char); } #if __cplusplus >= 201103L - static constexpr char + static constexpr char lowest() noexcept { return min(); } #endif @@ -474,10 +474,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR char + static _GLIBCXX_CONSTEXPR char epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR char + static _GLIBCXX_CONSTEXPR char round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -488,20 +488,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR + static _GLIBCXX_CONSTEXPR char infinity() _GLIBCXX_USE_NOEXCEPT { return char(); } - static _GLIBCXX_CONSTEXPR char + static _GLIBCXX_CONSTEXPR char quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); } - static _GLIBCXX_CONSTEXPR char + static _GLIBCXX_CONSTEXPR char signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); } - static _GLIBCXX_CONSTEXPR char + static _GLIBCXX_CONSTEXPR char denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<char>(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; @@ -510,7 +510,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -520,19 +520,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR signed char + static _GLIBCXX_CONSTEXPR signed char min() _GLIBCXX_USE_NOEXCEPT { return -__SCHAR_MAX__ - 1; } - static _GLIBCXX_CONSTEXPR signed char + static _GLIBCXX_CONSTEXPR signed char max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__; } #if __cplusplus >= 201103L - static constexpr signed char + static constexpr signed char lowest() noexcept { return min(); } #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (signed char); - static _GLIBCXX_USE_CONSTEXPR int digits10 + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (signed char); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; @@ -542,10 +542,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR signed char + static _GLIBCXX_CONSTEXPR signed char epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR signed char + static _GLIBCXX_CONSTEXPR signed char round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -556,21 +556,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR signed char + static _GLIBCXX_CONSTEXPR signed char infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<signed char>(0); } - static _GLIBCXX_CONSTEXPR signed char + static _GLIBCXX_CONSTEXPR signed char quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<signed char>(0); } - static _GLIBCXX_CONSTEXPR signed char + static _GLIBCXX_CONSTEXPR signed char signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<signed char>(0); } - static _GLIBCXX_CONSTEXPR signed char + static _GLIBCXX_CONSTEXPR signed char denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<signed char>(0); } @@ -580,7 +580,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -590,20 +590,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR unsigned char + static _GLIBCXX_CONSTEXPR unsigned char min() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned char + static _GLIBCXX_CONSTEXPR unsigned char max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__ * 2U + 1; } #if __cplusplus >= 201103L - static constexpr unsigned char + static constexpr unsigned char lowest() noexcept { return min(); } #endif - static _GLIBCXX_USE_CONSTEXPR int digits + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned char); - static _GLIBCXX_USE_CONSTEXPR int digits10 + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned char); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; @@ -613,10 +613,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR unsigned char + static _GLIBCXX_CONSTEXPR unsigned char epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned char + static _GLIBCXX_CONSTEXPR unsigned char round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -627,23 +627,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR unsigned char + static _GLIBCXX_CONSTEXPR unsigned char infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned char>(0); } - static _GLIBCXX_CONSTEXPR unsigned char + static _GLIBCXX_CONSTEXPR unsigned char quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned char>(0); } - static _GLIBCXX_CONSTEXPR unsigned char + static _GLIBCXX_CONSTEXPR unsigned char signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned char>(0); } - static _GLIBCXX_CONSTEXPR unsigned char + static _GLIBCXX_CONSTEXPR unsigned char denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned char>(0); } @@ -653,7 +653,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -663,10 +663,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR wchar_t + static _GLIBCXX_CONSTEXPR wchar_t min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); } - static _GLIBCXX_CONSTEXPR wchar_t + static _GLIBCXX_CONSTEXPR wchar_t max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (wchar_t); } #if __cplusplus >= 201103L @@ -675,7 +675,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (wchar_t); - static _GLIBCXX_USE_CONSTEXPR int digits10 + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (wchar_t); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; @@ -685,10 +685,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR wchar_t + static _GLIBCXX_CONSTEXPR wchar_t epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR wchar_t + static _GLIBCXX_CONSTEXPR wchar_t round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -699,20 +699,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR wchar_t + static _GLIBCXX_CONSTEXPR wchar_t infinity() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } - static _GLIBCXX_CONSTEXPR wchar_t + static _GLIBCXX_CONSTEXPR wchar_t quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } - static _GLIBCXX_CONSTEXPR wchar_t + static _GLIBCXX_CONSTEXPR wchar_t signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } - static _GLIBCXX_CONSTEXPR wchar_t + static _GLIBCXX_CONSTEXPR wchar_t denorm_min() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; @@ -721,7 +721,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -732,13 +732,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static constexpr bool is_specialized = true; - static constexpr char16_t + static constexpr char16_t min() noexcept { return __glibcxx_min (char16_t); } - static constexpr char16_t + static constexpr char16_t max() noexcept { return __glibcxx_max (char16_t); } - static constexpr char16_t + static constexpr char16_t lowest() noexcept { return min(); } static constexpr int digits = __glibcxx_digits (char16_t); @@ -749,10 +749,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr bool is_exact = true; static constexpr int radix = 2; - static constexpr char16_t + static constexpr char16_t epsilon() noexcept { return 0; } - static constexpr char16_t + static constexpr char16_t round_error() noexcept { return 0; } static constexpr int min_exponent = 0; @@ -766,16 +766,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; - static constexpr char16_t + static constexpr char16_t infinity() noexcept { return char16_t(); } - static constexpr char16_t + static constexpr char16_t quiet_NaN() noexcept { return char16_t(); } - static constexpr char16_t + static constexpr char16_t signaling_NaN() noexcept { return char16_t(); } - static constexpr char16_t + static constexpr char16_t denorm_min() noexcept { return char16_t(); } static constexpr bool is_iec559 = false; @@ -793,13 +793,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static constexpr bool is_specialized = true; - static constexpr char32_t + static constexpr char32_t min() noexcept { return __glibcxx_min (char32_t); } - static constexpr char32_t + static constexpr char32_t max() noexcept { return __glibcxx_max (char32_t); } - static constexpr char32_t + static constexpr char32_t lowest() noexcept { return min(); } static constexpr int digits = __glibcxx_digits (char32_t); @@ -810,10 +810,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr bool is_exact = true; static constexpr int radix = 2; - static constexpr char32_t + static constexpr char32_t epsilon() noexcept { return 0; } - static constexpr char32_t + static constexpr char32_t round_error() noexcept { return 0; } static constexpr int min_exponent = 0; @@ -827,16 +827,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; - static constexpr char32_t + static constexpr char32_t infinity() noexcept { return char32_t(); } - static constexpr char32_t + static constexpr char32_t quiet_NaN() noexcept { return char32_t(); } - static constexpr char32_t + static constexpr char32_t signaling_NaN() noexcept { return char32_t(); } - static constexpr char32_t + static constexpr char32_t denorm_min() noexcept { return char32_t(); } static constexpr bool is_iec559 = false; @@ -855,14 +855,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR short + static _GLIBCXX_CONSTEXPR short min() _GLIBCXX_USE_NOEXCEPT { return -__SHRT_MAX__ - 1; } - static _GLIBCXX_CONSTEXPR short + static _GLIBCXX_CONSTEXPR short max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__; } #if __cplusplus >= 201103L - static constexpr short + static constexpr short lowest() noexcept { return min(); } #endif @@ -876,10 +876,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR short + static _GLIBCXX_CONSTEXPR short epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR short + static _GLIBCXX_CONSTEXPR short round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -890,20 +890,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR short + static _GLIBCXX_CONSTEXPR short infinity() _GLIBCXX_USE_NOEXCEPT { return short(); } - static _GLIBCXX_CONSTEXPR short + static _GLIBCXX_CONSTEXPR short quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); } - static _GLIBCXX_CONSTEXPR short + static _GLIBCXX_CONSTEXPR short signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); } - static _GLIBCXX_CONSTEXPR short + static _GLIBCXX_CONSTEXPR short denorm_min() _GLIBCXX_USE_NOEXCEPT { return short(); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; @@ -912,7 +912,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -922,20 +922,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR unsigned short + static _GLIBCXX_CONSTEXPR unsigned short min() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned short + static _GLIBCXX_CONSTEXPR unsigned short max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__ * 2U + 1; } #if __cplusplus >= 201103L - static constexpr unsigned short + static constexpr unsigned short lowest() noexcept { return min(); } #endif - static _GLIBCXX_USE_CONSTEXPR int digits + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned short); - static _GLIBCXX_USE_CONSTEXPR int digits10 + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned short); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; @@ -945,10 +945,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR unsigned short + static _GLIBCXX_CONSTEXPR unsigned short epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned short + static _GLIBCXX_CONSTEXPR unsigned short round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -959,23 +959,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR unsigned short + static _GLIBCXX_CONSTEXPR unsigned short infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned short>(0); } - static _GLIBCXX_CONSTEXPR unsigned short + static _GLIBCXX_CONSTEXPR unsigned short quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned short>(0); } - static _GLIBCXX_CONSTEXPR unsigned short + static _GLIBCXX_CONSTEXPR unsigned short signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned short>(0); } - static _GLIBCXX_CONSTEXPR unsigned short + static _GLIBCXX_CONSTEXPR unsigned short denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned short>(0); } @@ -985,7 +985,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -995,14 +995,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR int + static _GLIBCXX_CONSTEXPR int min() _GLIBCXX_USE_NOEXCEPT { return -__INT_MAX__ - 1; } - static _GLIBCXX_CONSTEXPR int + static _GLIBCXX_CONSTEXPR int max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__; } #if __cplusplus >= 201103L - static constexpr int + static constexpr int lowest() noexcept { return min(); } #endif @@ -1016,10 +1016,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR int + static _GLIBCXX_CONSTEXPR int epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR int + static _GLIBCXX_CONSTEXPR int round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -1030,20 +1030,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR int + static _GLIBCXX_CONSTEXPR int infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); } - static _GLIBCXX_CONSTEXPR int + static _GLIBCXX_CONSTEXPR int quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); } - static _GLIBCXX_CONSTEXPR int + static _GLIBCXX_CONSTEXPR int signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); } - static _GLIBCXX_CONSTEXPR int + static _GLIBCXX_CONSTEXPR int denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; @@ -1052,7 +1052,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -1062,20 +1062,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR unsigned int + static _GLIBCXX_CONSTEXPR unsigned int min() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned int + static _GLIBCXX_CONSTEXPR unsigned int max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__ * 2U + 1; } #if __cplusplus >= 201103L - static constexpr unsigned int + static constexpr unsigned int lowest() noexcept { return min(); } #endif - static _GLIBCXX_USE_CONSTEXPR int digits + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned int); - static _GLIBCXX_USE_CONSTEXPR int digits10 + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned int); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; @@ -1085,10 +1085,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR unsigned int + static _GLIBCXX_CONSTEXPR unsigned int epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned int + static _GLIBCXX_CONSTEXPR unsigned int round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -1099,22 +1099,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR unsigned int + static _GLIBCXX_CONSTEXPR unsigned int infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned int>(0); } - static _GLIBCXX_CONSTEXPR unsigned int + static _GLIBCXX_CONSTEXPR unsigned int quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned int>(0); } - static _GLIBCXX_CONSTEXPR unsigned int + static _GLIBCXX_CONSTEXPR unsigned int signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned int>(0); } - static _GLIBCXX_CONSTEXPR unsigned int + static _GLIBCXX_CONSTEXPR unsigned int denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned int>(0); } @@ -1124,7 +1124,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -1137,11 +1137,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_CONSTEXPR long min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_MAX__ - 1; } - static _GLIBCXX_CONSTEXPR long + static _GLIBCXX_CONSTEXPR long max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__; } #if __cplusplus >= 201103L - static constexpr long + static constexpr long lowest() noexcept { return min(); } #endif @@ -1155,10 +1155,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR long + static _GLIBCXX_CONSTEXPR long epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR long + static _GLIBCXX_CONSTEXPR long round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -1169,20 +1169,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR long + static _GLIBCXX_CONSTEXPR long infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); } - static _GLIBCXX_CONSTEXPR long + static _GLIBCXX_CONSTEXPR long quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); } - static _GLIBCXX_CONSTEXPR long + static _GLIBCXX_CONSTEXPR long signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); } - static _GLIBCXX_CONSTEXPR long + static _GLIBCXX_CONSTEXPR long denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; @@ -1191,7 +1191,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -1201,20 +1201,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR unsigned long + static _GLIBCXX_CONSTEXPR unsigned long min() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned long + static _GLIBCXX_CONSTEXPR unsigned long max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__ * 2UL + 1; } #if __cplusplus >= 201103L - static constexpr unsigned long + static constexpr unsigned long lowest() noexcept { return min(); } #endif - static _GLIBCXX_USE_CONSTEXPR int digits + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned long); - static _GLIBCXX_USE_CONSTEXPR int digits10 + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned long); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; @@ -1224,10 +1224,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR unsigned long + static _GLIBCXX_CONSTEXPR unsigned long epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned long + static _GLIBCXX_CONSTEXPR unsigned long round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -1238,23 +1238,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR unsigned long + static _GLIBCXX_CONSTEXPR unsigned long infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned long>(0); } - static _GLIBCXX_CONSTEXPR unsigned long + static _GLIBCXX_CONSTEXPR unsigned long quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned long>(0); } - static _GLIBCXX_CONSTEXPR unsigned long + static _GLIBCXX_CONSTEXPR unsigned long signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned long>(0); } - static _GLIBCXX_CONSTEXPR unsigned long + static _GLIBCXX_CONSTEXPR unsigned long denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned long>(0); } @@ -1264,7 +1264,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -1274,20 +1274,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR long long + static _GLIBCXX_CONSTEXPR long long min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_LONG_MAX__ - 1; } - static _GLIBCXX_CONSTEXPR long long + static _GLIBCXX_CONSTEXPR long long max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__; } #if __cplusplus >= 201103L - static constexpr long long + static constexpr long long lowest() noexcept { return min(); } #endif - static _GLIBCXX_USE_CONSTEXPR int digits + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (long long); - static _GLIBCXX_USE_CONSTEXPR int digits10 + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (long long); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; @@ -1297,10 +1297,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR long long + static _GLIBCXX_CONSTEXPR long long epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR long long + static _GLIBCXX_CONSTEXPR long long round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -1311,21 +1311,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR long long + static _GLIBCXX_CONSTEXPR long long infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); } - static _GLIBCXX_CONSTEXPR long long + static _GLIBCXX_CONSTEXPR long long quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); } - static _GLIBCXX_CONSTEXPR long long + static _GLIBCXX_CONSTEXPR long long signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); } - static _GLIBCXX_CONSTEXPR long long + static _GLIBCXX_CONSTEXPR long long denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; @@ -1334,7 +1334,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -1344,20 +1344,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR unsigned long long + static _GLIBCXX_CONSTEXPR unsigned long long min() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned long long + static _GLIBCXX_CONSTEXPR unsigned long long max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__ * 2ULL + 1; } #if __cplusplus >= 201103L - static constexpr unsigned long long + static constexpr unsigned long long lowest() noexcept { return min(); } #endif - static _GLIBCXX_USE_CONSTEXPR int digits + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (unsigned long long); - static _GLIBCXX_USE_CONSTEXPR int digits10 + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (unsigned long long); #if __cplusplus >= 201103L static constexpr int max_digits10 = 0; @@ -1367,10 +1367,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; static _GLIBCXX_USE_CONSTEXPR int radix = 2; - static _GLIBCXX_CONSTEXPR unsigned long long + static _GLIBCXX_CONSTEXPR unsigned long long epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned long long + static _GLIBCXX_CONSTEXPR unsigned long long round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; @@ -1381,23 +1381,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - static _GLIBCXX_CONSTEXPR unsigned long long + static _GLIBCXX_CONSTEXPR unsigned long long infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned long long>(0); } - static _GLIBCXX_CONSTEXPR unsigned long long + static _GLIBCXX_CONSTEXPR unsigned long long quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned long long>(0); } - static _GLIBCXX_CONSTEXPR unsigned long long + static _GLIBCXX_CONSTEXPR unsigned long long signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned long long>(0); } - static _GLIBCXX_CONSTEXPR unsigned long long + static _GLIBCXX_CONSTEXPR unsigned long long denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned long long>(0); } @@ -1407,7 +1407,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_toward_zero; }; @@ -1595,14 +1595,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR float + static _GLIBCXX_CONSTEXPR float min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MIN__; } - static _GLIBCXX_CONSTEXPR float + static _GLIBCXX_CONSTEXPR float max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; } #if __cplusplus >= 201103L - static constexpr float + static constexpr float lowest() noexcept { return -__FLT_MAX__; } #endif @@ -1617,10 +1617,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__; - static _GLIBCXX_CONSTEXPR float + static _GLIBCXX_CONSTEXPR float epsilon() _GLIBCXX_USE_NOEXCEPT { return __FLT_EPSILON__; } - static _GLIBCXX_CONSTEXPR float + static _GLIBCXX_CONSTEXPR float round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5F; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = __FLT_MIN_EXP__; @@ -1633,19 +1633,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent; - static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = __glibcxx_float_has_denorm_loss; - static _GLIBCXX_CONSTEXPR float + static _GLIBCXX_CONSTEXPR float infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_valf(); } - static _GLIBCXX_CONSTEXPR float + static _GLIBCXX_CONSTEXPR float quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanf(""); } - static _GLIBCXX_CONSTEXPR float + static _GLIBCXX_CONSTEXPR float signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansf(""); } - static _GLIBCXX_CONSTEXPR float + static _GLIBCXX_CONSTEXPR float denorm_min() _GLIBCXX_USE_NOEXCEPT { return __FLT_DENORM_MIN__; } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 @@ -1654,9 +1654,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_float_traps; - static _GLIBCXX_USE_CONSTEXPR bool tinyness_before + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = __glibcxx_float_tinyness_before; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_to_nearest; }; @@ -1670,14 +1670,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR double + static _GLIBCXX_CONSTEXPR double min() _GLIBCXX_USE_NOEXCEPT { return __DBL_MIN__; } - static _GLIBCXX_CONSTEXPR double + static _GLIBCXX_CONSTEXPR double max() _GLIBCXX_USE_NOEXCEPT { return __DBL_MAX__; } #if __cplusplus >= 201103L - static constexpr double + static constexpr double lowest() noexcept { return -__DBL_MAX__; } #endif @@ -1692,10 +1692,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__; - static _GLIBCXX_CONSTEXPR double + static _GLIBCXX_CONSTEXPR double epsilon() _GLIBCXX_USE_NOEXCEPT { return __DBL_EPSILON__; } - static _GLIBCXX_CONSTEXPR double + static _GLIBCXX_CONSTEXPR double round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = __DBL_MIN_EXP__; @@ -1708,19 +1708,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN; static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent; - static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = __glibcxx_double_has_denorm_loss; - static _GLIBCXX_CONSTEXPR double + static _GLIBCXX_CONSTEXPR double infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_val(); } - static _GLIBCXX_CONSTEXPR double + static _GLIBCXX_CONSTEXPR double quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nan(""); } - static _GLIBCXX_CONSTEXPR double + static _GLIBCXX_CONSTEXPR double signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nans(""); } - static _GLIBCXX_CONSTEXPR double + static _GLIBCXX_CONSTEXPR double denorm_min() _GLIBCXX_USE_NOEXCEPT { return __DBL_DENORM_MIN__; } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 @@ -1729,9 +1729,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_double_traps; - static _GLIBCXX_USE_CONSTEXPR bool tinyness_before + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = __glibcxx_double_tinyness_before; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_to_nearest; }; @@ -1745,14 +1745,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - static _GLIBCXX_CONSTEXPR long double + static _GLIBCXX_CONSTEXPR long double min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MIN__; } - static _GLIBCXX_CONSTEXPR long double + static _GLIBCXX_CONSTEXPR long double max() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MAX__; } #if __cplusplus >= 201103L - static constexpr long double + static constexpr long double lowest() noexcept { return -__LDBL_MAX__; } #endif @@ -1767,10 +1767,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__; - static _GLIBCXX_CONSTEXPR long double + static _GLIBCXX_CONSTEXPR long double epsilon() _GLIBCXX_USE_NOEXCEPT { return __LDBL_EPSILON__; } - static _GLIBCXX_CONSTEXPR long double + static _GLIBCXX_CONSTEXPR long double round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5L; } static _GLIBCXX_USE_CONSTEXPR int min_exponent = __LDBL_MIN_EXP__; @@ -1786,16 +1786,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = __glibcxx_long_double_has_denorm_loss; - static _GLIBCXX_CONSTEXPR long double + static _GLIBCXX_CONSTEXPR long double infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_vall(); } - static _GLIBCXX_CONSTEXPR long double + static _GLIBCXX_CONSTEXPR long double quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanl(""); } - static _GLIBCXX_CONSTEXPR long double + static _GLIBCXX_CONSTEXPR long double signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansl(""); } - static _GLIBCXX_CONSTEXPR long double + static _GLIBCXX_CONSTEXPR long double denorm_min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_DENORM_MIN__; } static _GLIBCXX_USE_CONSTEXPR bool is_iec559 @@ -1804,9 +1804,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_long_double_traps; - static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = __glibcxx_long_double_tinyness_before; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = round_to_nearest; }; diff --git a/libstdc++-v3/include/std/ratio b/libstdc++-v3/include/std/ratio index 6c9a1174d91..9d7b61cd840 100644 --- a/libstdc++-v3/include/std/ratio +++ b/libstdc++-v3/include/std/ratio @@ -3,14 +3,14 @@ // Copyright (C) 2008-2016 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional @@ -94,11 +94,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static const uintmax_t __b0 = __static_abs<_Qn>::value % __c; static const uintmax_t __b1 = __static_abs<_Qn>::value / __c; - static_assert(__a1 == 0 || __b1 == 0, + static_assert(__a1 == 0 || __b1 == 0, "overflow in multiplication"); - static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1), + static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1), "overflow in multiplication"); - static_assert(__b0 * __a0 <= __INTMAX_MAX__, + static_assert(__b0 * __a0 <= __INTMAX_MAX__, "overflow in multiplication"); static_assert((__a0 * __b1 + __b0 * __a1) * __c <= __INTMAX_MAX__ - __b0 * __a0, @@ -257,7 +257,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * std::ratio<7,-21>::num == -1; * std::ratio<7,-21>::den == 3; * @endcode - * + * */ template<intmax_t _Num, intmax_t _Den = 1> struct ratio @@ -340,7 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct ratio_equal : integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den> { }; - + /// ratio_not_equal template<typename _R1, typename _R2> struct ratio_not_equal @@ -354,7 +354,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __ratio_less_impl_1 : integral_constant<bool, __big_less<_Left::__hi, _Left::__lo, _Right::__hi, _Right::__lo>::value> - { }; + { }; template<typename _R1, typename _R2, bool = (_R1::num == 0 || _R2::num == 0 @@ -382,13 +382,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct ratio_less : __ratio_less_impl<_R1, _R2>::type { }; - + /// ratio_less_equal template<typename _R1, typename _R2> struct ratio_less_equal : integral_constant<bool, !ratio_less<_R2, _R1>::value> { }; - + /// ratio_greater template<typename _R1, typename _R2> struct ratio_greater diff --git a/libstdc++-v3/include/std/scoped_allocator b/libstdc++-v3/include/std/scoped_allocator index aac2dfee664..310c85c6507 100644 --- a/libstdc++-v3/include/std/scoped_allocator +++ b/libstdc++-v3/include/std/scoped_allocator @@ -68,7 +68,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _OuterAlloc, typename... _InnerAllocs> class scoped_allocator_adaptor; - template<typename...> + template<typename...> struct __inner_type_impl; template<typename _Outer> @@ -81,25 +81,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __inner_type_impl(__inner_type_impl&&) = default; __inner_type_impl& operator=(const __inner_type_impl&) = default; __inner_type_impl& operator=(__inner_type_impl&&) = default; - + template<typename _Alloc> __inner_type_impl(const __inner_type_impl<_Alloc>& __other) { } - + template<typename _Alloc> __inner_type_impl(__inner_type_impl<_Alloc>&& __other) { } - - __type& + + __type& _M_get(__type* __p) noexcept { return *__p; } - const __type& + const __type& _M_get(const __type* __p) const noexcept { return *__p; } - - tuple<> + + tuple<> _M_tie() const noexcept { return tuple<>(); } - - bool + + bool operator==(const __inner_type_impl&) const noexcept { return true; } }; @@ -108,17 +108,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __inner_type_impl<_Outer, _InnerHead, _InnerTail...> { typedef scoped_allocator_adaptor<_InnerHead, _InnerTail...> __type; - + __inner_type_impl() = default; __inner_type_impl(const __inner_type_impl&) = default; __inner_type_impl(__inner_type_impl&&) = default; __inner_type_impl& operator=(const __inner_type_impl&) = default; __inner_type_impl& operator=(__inner_type_impl&&) = default; - + template<typename... _Allocs> __inner_type_impl(const __inner_type_impl<_Allocs...>& __other) : _M_inner(__other._M_inner) { } - + template<typename... _Allocs> __inner_type_impl(__inner_type_impl<_Allocs...>&& __other) : _M_inner(std::move(__other._M_inner)) { } @@ -128,24 +128,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __inner_type_impl(_Args&&... __args) : _M_inner(std::forward<_Args>(__args)...) { } - __type& + __type& _M_get(void*) noexcept { return _M_inner; } - - const __type& + + const __type& _M_get(const void*) const noexcept { return _M_inner; } - - tuple<const _InnerHead&, const _InnerTail&...> + + tuple<const _InnerHead&, const _InnerTail&...> _M_tie() const noexcept { return _M_inner._M_tie(); } - - bool + + bool operator==(const __inner_type_impl& __other) const noexcept { return _M_inner == __other._M_inner; } - + private: template<typename...> friend class __inner_type_impl; template<typename, typename...> friend class scoped_allocator_adaptor; - + __type _M_inner; }; @@ -176,9 +176,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Alloc> using __outermost_alloc_traits = allocator_traits<__outermost_type<_Alloc>>; - + template<typename _Tp, typename... _Args> - void + void _M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args) { typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits; @@ -190,7 +190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __uses_alloc2<typename __inner_type::__type> __uses_alloc2_; template<typename _Tp, typename... _Args> - void + void _M_construct(__uses_alloc1_, _Tp* __p, _Args&&... __args) { typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits; @@ -200,7 +200,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp, typename... _Args> - void + void _M_construct(__uses_alloc2_, _Tp* __p, _Args&&... __args) { typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits; diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream index de6cdf15308..bfe2ca1cdac 100644 --- a/libstdc++-v3/include/std/sstream +++ b/libstdc++-v3/include/std/sstream @@ -209,7 +209,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 virtual streamsize showmanyc() - { + { streamsize __ret = -1; if (_M_mode & ios_base::in) { @@ -248,10 +248,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 // that an external char_type array of length __n exists // and has been pre-allocated. If this is not the case, // things will quickly blow up. - + // Step 1: Destroy the current internal array. _M_string.clear(); - + // Step 2: Use the external array. _M_sync(__s, __n, 0); } diff --git a/libstdc++-v3/include/std/stdexcept b/libstdc++-v3/include/std/stdexcept index aef27cc3617..459bc02db8f 100644 --- a/libstdc++-v3/include/std/stdexcept +++ b/libstdc++-v3/include/std/stdexcept @@ -110,13 +110,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * program runs (e.g., violations of class invariants). * @brief One of two subclasses of exception. */ - class logic_error : public exception + class logic_error : public exception { __cow_string _M_msg; public: /** Takes a character string describing the error. */ - explicit + explicit logic_error(const string& __arg) _GLIBCXX_TXN_SAFE; #if __cplusplus >= 201103L @@ -133,7 +133,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /** Returns a C-style character string describing the general cause of * the current error (the same string passed to the ctor). */ - virtual const char* + virtual const char* what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT; # ifdef _GLIBCXX_TM_TS_INTERNAL @@ -144,7 +144,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /** Thrown by the library, or by you, to report domain errors (domain in * the mathematical sense). */ - class domain_error : public logic_error + class domain_error : public logic_error { public: explicit domain_error(const string& __arg) _GLIBCXX_TXN_SAFE; @@ -155,7 +155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /** Thrown to report invalid arguments to functions. */ - class invalid_argument : public logic_error + class invalid_argument : public logic_error { public: explicit invalid_argument(const string& __arg) _GLIBCXX_TXN_SAFE; @@ -167,7 +167,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /** Thrown when an object is constructed that would exceed its maximum * permitted size (e.g., a basic_string instance). */ - class length_error : public logic_error + class length_error : public logic_error { public: explicit length_error(const string& __arg) _GLIBCXX_TXN_SAFE; @@ -179,7 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /** This represents an argument whose value is not within the expected * range (e.g., boundary checks in basic_string). */ - class out_of_range : public logic_error + class out_of_range : public logic_error { public: explicit out_of_range(const string& __arg) _GLIBCXX_TXN_SAFE; @@ -194,13 +194,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * the program executes. * @brief One of two subclasses of exception. */ - class runtime_error : public exception + class runtime_error : public exception { __cow_string _M_msg; public: /** Takes a character string describing the error. */ - explicit + explicit runtime_error(const string& __arg) _GLIBCXX_TXN_SAFE; #if __cplusplus >= 201103L @@ -217,7 +217,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /** Returns a C-style character string describing the general cause of * the current error (the same string passed to the ctor). */ - virtual const char* + virtual const char* what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT; # ifdef _GLIBCXX_TM_TS_INTERNAL @@ -227,7 +227,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /** Thrown to indicate range errors in internal computations. */ - class range_error : public runtime_error + class range_error : public runtime_error { public: explicit range_error(const string& __arg) _GLIBCXX_TXN_SAFE; @@ -238,7 +238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /** Thrown to indicate arithmetic overflow. */ - class overflow_error : public runtime_error + class overflow_error : public runtime_error { public: explicit overflow_error(const string& __arg) _GLIBCXX_TXN_SAFE; @@ -249,7 +249,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /** Thrown to indicate arithmetic underflow. */ - class underflow_error : public runtime_error + class underflow_error : public runtime_error { public: explicit underflow_error(const string& __arg) _GLIBCXX_TXN_SAFE; diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string index 28c56779079..77f899ab63a 100644 --- a/libstdc++-v3/include/std/string +++ b/libstdc++-v3/include/std/string @@ -46,10 +46,10 @@ #include <bits/stl_iterator_base_funcs.h> #include <bits/stl_iterator.h> #include <bits/stl_function.h> // For less -#include <ext/numeric_traits.h> -#include <bits/stl_algobase.h> +#include <ext/numeric_traits.h> +#include <bits/stl_algobase.h> #include <bits/range_access.h> #include <bits/basic_string.h> -#include <bits/basic_string.tcc> +#include <bits/basic_string.tcc> #endif /* _GLIBCXX_STRING */ diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index b871c1e4396..79320fac598 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -56,7 +56,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> struct is_error_condition_enum : public false_type { }; - template<> + template<> struct is_error_condition_enum<errc> : public true_type { }; @@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION error_category(const error_category&) = delete; error_category& operator=(const error_category&) = delete; - virtual const char* + virtual const char* name() const noexcept = 0; // We need two different virtual functions here, one returning a @@ -91,7 +91,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION virtual string message(int) const = 0; #else - virtual string + virtual string message(int) const = 0; private: @@ -103,21 +103,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION virtual error_condition default_error_condition(int __i) const noexcept; - virtual bool + virtual bool equivalent(int __i, const error_condition& __cond) const noexcept; - virtual bool + virtual bool equivalent(const error_code& __code, int __i) const noexcept; - bool + bool operator<(const error_category& __other) const noexcept { return less<const error_category*>()(this, &__other); } - bool + bool operator==(const error_category& __other) const noexcept { return this == &__other; } - bool + bool operator!=(const error_category& __other) const noexcept { return this != &__other; } }; @@ -148,14 +148,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION error_code(_ErrorCodeEnum __e) noexcept { *this = make_error_code(__e); } - void + void assign(int __v, const error_category& __cat) noexcept { _M_value = __v; - _M_cat = &__cat; + _M_cat = &__cat; } - void + void clear() noexcept { assign(0, system_category()); } @@ -168,15 +168,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION int value() const noexcept { return _M_value; } - - const error_category& + + const error_category& category() const noexcept { return *_M_cat; } - error_condition + error_condition default_error_condition() const noexcept; _GLIBCXX_DEFAULT_ABI_TAG - string + string message() const { return category().message(value()); } @@ -198,7 +198,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline bool operator<(const error_code& __lhs, const error_code& __rhs) noexcept - { + { return (__lhs.category() < __rhs.category() || (__lhs.category() == __rhs.category() && __lhs.value() < __rhs.value())); @@ -213,7 +213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// error_condition // Portable error identification - struct error_condition + struct error_condition { error_condition() noexcept : _M_value(0), _M_cat(&generic_category()) { } @@ -240,7 +240,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator=(_ErrorConditionEnum __e) noexcept { return *this = make_error_condition(__e); } - void + void clear() noexcept { assign(0, generic_category()); } @@ -252,7 +252,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION category() const noexcept { return *_M_cat; } _GLIBCXX_DEFAULT_ABI_TAG - string + string message() const { return category().message(value()); } @@ -270,7 +270,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION make_error_condition(errc __e) noexcept { return error_condition(static_cast<int>(__e), generic_category()); } - inline bool + inline bool operator<(const error_condition& __lhs, const error_condition& __rhs) noexcept { @@ -325,7 +325,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !(__lhs == __rhs); } - /** + /** * @brief Thrown to indicate error code of underlying system. * * @ingroup exceptions @@ -358,7 +358,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION virtual ~system_error() noexcept; - const error_code& + const error_code& code() const noexcept { return _M_code; } }; diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread index 15aa9a9b577..7e185d310dd 100644 --- a/libstdc++-v3/include/std/thread +++ b/libstdc++-v3/include/std/thread @@ -112,7 +112,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { swap(__t); } template<typename _Callable, typename... _Args> - explicit + explicit thread(_Callable&& __f, _Args&&... __args) { #ifdef GTHR_ACTIVE_PROXY diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 17c82049030..180a34629f8 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -48,7 +48,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ - template<std::size_t _Idx, typename _Head, bool _IsEmptyNotFinal> + template<typename... _Elements> + class tuple; + + template<typename _Tp> + struct __is_empty_non_tuple : is_empty<_Tp> { }; + + // Using EBO for elements that are tuples causes ambiguous base errors. + template<typename _El0, typename... _El> + struct __is_empty_non_tuple<tuple<_El0, _El...>> : false_type { }; + + // Use the Empty Base-class Optimization for empty, non-final types. + template<typename _Tp> + using __empty_not_final + = typename conditional<__is_final(_Tp), false_type, + __is_empty_non_tuple<_Tp>>::type; + + template<std::size_t _Idx, typename _Head, + bool = __empty_not_final<_Head>::value> struct _Head_base; template<std::size_t _Idx, typename _Head> @@ -156,20 +173,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * get() operation. */ template<std::size_t _Idx, typename... _Elements> - struct _Tuple_impl; - - template<typename _Tp> - struct __is_empty_non_tuple : is_empty<_Tp> { }; - - // Using EBO for elements that are tuples causes ambiguous base errors. - template<typename _El0, typename... _El> - struct __is_empty_non_tuple<tuple<_El0, _El...>> : false_type { }; - - // Use the Empty Base-class Optimization for empty, non-final types. - template<typename _Tp> - using __empty_not_final - = typename conditional<__is_final(_Tp), false_type, - __is_empty_non_tuple<_Tp>>::type; + struct _Tuple_impl; /** * Recursive tuple implementation. Here we store the @c Head element @@ -179,14 +183,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<std::size_t _Idx, typename _Head, typename... _Tail> struct _Tuple_impl<_Idx, _Head, _Tail...> : public _Tuple_impl<_Idx + 1, _Tail...>, - private _Head_base<_Idx, _Head, __empty_not_final<_Head>::value> + private _Head_base<_Idx, _Head> { template<std::size_t, typename...> friend class _Tuple_impl; typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited; - typedef _Head_base<_Idx, _Head, __empty_not_final<_Head>::value> _Base; + typedef _Head_base<_Idx, _Head> _Base; - static constexpr _Head& + static constexpr _Head& _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } static constexpr const _Head& @@ -201,12 +205,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr _Tuple_impl() : _Inherited(), _Base() { } - explicit + explicit constexpr _Tuple_impl(const _Head& __head, const _Tail&... __tail) : _Inherited(__tail...), _Base(__head) { } template<typename _UHead, typename... _UTail, typename = typename - enable_if<sizeof...(_Tail) == sizeof...(_UTail)>::type> + enable_if<sizeof...(_Tail) == sizeof...(_UTail)>::type> explicit constexpr _Tuple_impl(_UHead&& __head, _UTail&&... __tail) : _Inherited(std::forward<_UTail>(__tail)...), @@ -218,7 +222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tuple_impl(_Tuple_impl&& __in) noexcept(__and_<is_nothrow_move_constructible<_Head>, is_nothrow_move_constructible<_Inherited>>::value) - : _Inherited(std::move(_M_tail(__in))), + : _Inherited(std::move(_M_tail(__in))), _Base(std::forward<_Head>(_M_head(__in))) { } template<typename... _UElements> @@ -256,13 +260,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, const _Tuple_impl& __in) - : _Inherited(__tag, __a, _M_tail(__in)), + : _Inherited(__tag, __a, _M_tail(__in)), _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { } template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl&& __in) - : _Inherited(__tag, __a, std::move(_M_tail(__in))), + : _Inherited(__tag, __a, std::move(_M_tail(__in))), _Base(__use_alloc<_Head, _Alloc, _Head>(__a), std::forward<_Head>(_M_head(__in))) { } @@ -336,11 +340,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Basis case of inheritance recursion. template<std::size_t _Idx, typename _Head> struct _Tuple_impl<_Idx, _Head> - : private _Head_base<_Idx, _Head, __empty_not_final<_Head>::value> + : private _Head_base<_Idx, _Head> { template<std::size_t, typename...> friend class _Tuple_impl; - typedef _Head_base<_Idx, _Head, __empty_not_final<_Head>::value> _Base; + typedef _Head_base<_Idx, _Head> _Base; static constexpr _Head& _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } @@ -457,9 +461,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } }; - template<typename... _Elements> - class tuple; - // Concept utility functions, reused in conditionally-explicit // constructors. template<bool, typename... _Elements> @@ -550,7 +551,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// Primary class template, tuple - template<typename... _Elements> + template<typename... _Elements> class tuple : public _Tuple_impl<0, _Elements...> { typedef _Tuple_impl<0, _Elements...> _Inherited; @@ -657,7 +658,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr tuple(const tuple&) = default; - constexpr tuple(tuple&&) = default; + constexpr tuple(tuple&&) = default; // Shortcut for the cases where constructors taking tuples // must avoid creating temporaries. @@ -876,6 +877,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: void swap(tuple&) noexcept { /* no-op */ } + // We need the default since we're going to define no-op + // allocator constructors. + tuple() = default; + // No-op allocator constructors. + template<typename _Alloc> + tuple(allocator_arg_t, const _Alloc&) { } + template<typename _Alloc> + tuple(allocator_arg_t, const _Alloc&, const tuple&) { } }; /// Partial specialization, 2-element tuple. @@ -1330,7 +1339,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return bool(std::get<__i>(__t) == std::get<__i>(__u)) && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u); } - + static constexpr bool __less(const _Tp& __t, const _Up& __u) { @@ -1345,7 +1354,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static constexpr bool __eq(const _Tp&, const _Up&) { return true; } - + static constexpr bool __less(const _Tp&, const _Up&) { return false; } }; @@ -1560,7 +1569,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// swap template<typename... _Elements> - inline void + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__and_<__is_swappable<_Elements>...>::value + >::type +#else + void +#endif swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 3a2b546b22f..e5c0d468f92 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -79,7 +79,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr value_type operator()() const { return value; } #endif }; - + template<typename _Tp, _Tp __v> constexpr _Tp integral_constant<_Tp, __v>::value; @@ -212,7 +212,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct __is_integral_helper<bool> : public true_type { }; - + template<> struct __is_integral_helper<char> : public true_type { }; @@ -648,7 +648,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> struct is_const<_Tp const> : public true_type { }; - + /// is_volatile template<typename> struct is_volatile @@ -766,7 +766,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __is_array_unknown_bounds : public __and_<is_array<_Tp>, __not_<extent<_Tp>>> { }; - + // In N3290 is_destructible does not say anything about function // types and abstract types, see LWG 2049. This implementation // describes function types as non-destructible and all complete @@ -889,9 +889,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __is_default_constructible_safe; // The following technique is a workaround for a current core language - // restriction, which does not allow for array types to occur in + // restriction, which does not allow for array types to occur in // functional casts of the form T(). Complete arrays can be default- - // constructed, if the element type is default-constructible, but + // constructed, if the element type is default-constructible, but // arrays with unknown bounds are not. template<typename _Tp> struct __is_default_constructible_safe<_Tp, true> @@ -919,7 +919,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // This implementation uses different strategies depending on the // target type to reduce the test overhead as much as possible: // - // a) For a reference target type, we use a static_cast expression + // a) For a reference target type, we use a static_cast expression // modulo its extra cases. // // b) For a non-reference target type we use a ::new expression. @@ -990,7 +990,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct remove_reference; template<typename _From, typename _To, bool - = __not_<__or_<is_void<_From>, + = __not_<__or_<is_void<_From>, is_function<_From>>>::value> struct __is_base_to_derived_ref; @@ -1027,7 +1027,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _From>::type>::type __src_t; typedef typename remove_cv<typename remove_reference< _To>::type>::type __dst_t; - typedef __and_<__not_<is_function<__src_t>>, + typedef __and_<__not_<is_function<__src_t>>, __or_<is_same<__src_t, __dst_t>, is_base_of<__dst_t, __src_t>>> type; static constexpr bool value = type::value; @@ -1038,11 +1038,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public false_type { }; - // Here we handle direct-initialization to a reference type as + // Here we handle direct-initialization to a reference type as // equivalent to a static_cast modulo overshooting conversions. // These are restricted to the following conversions: // a) A base class value to a derived class reference - // b) An lvalue to an rvalue-reference of reference-compatible + // b) An lvalue to an rvalue-reference of reference-compatible // types that are not functions template<typename _Tp, typename _Arg> struct __is_direct_constructible_ref_cast @@ -1350,7 +1350,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __and_<is_constructible<_Tp, _Args...>, integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>> { }; - + /// is_trivially_default_constructible template<typename _Tp> struct is_trivially_default_constructible @@ -1390,15 +1390,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_trivially_copy_constructible template<typename _Tp> struct is_trivially_copy_constructible - : public __and_<is_copy_constructible<_Tp>, + : public __and_<is_copy_constructible<_Tp>, integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>> { }; - + /// is_trivially_move_constructible template<typename _Tp> struct is_trivially_move_constructible - : public __and_<is_move_constructible<_Tp>, + : public __and_<is_move_constructible<_Tp>, integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&&)>> { }; @@ -1406,7 +1406,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_trivially_assignable template<typename _Tp, typename _Up> struct is_trivially_assignable - : public __and_<is_assignable<_Tp, _Up>, + : public __and_<is_assignable<_Tp, _Up>, integral_constant<bool, __is_trivially_assignable(_Tp, _Up)>> { }; @@ -1414,7 +1414,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_trivially_copy_assignable template<typename _Tp> struct is_trivially_copy_assignable - : public __and_<is_copy_assignable<_Tp>, + : public __and_<is_copy_assignable<_Tp>, integral_constant<bool, __is_trivially_assignable(_Tp&, const _Tp&)>> { }; @@ -1422,7 +1422,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_trivially_move_assignable template<typename _Tp> struct is_trivially_move_assignable - : public __and_<is_move_assignable<_Tp>, + : public __and_<is_move_assignable<_Tp>, integral_constant<bool, __is_trivially_assignable(_Tp&, _Tp&&)>> { }; @@ -1458,19 +1458,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public integral_constant<bool, __has_virtual_destructor(_Tp)> { }; - + // type property queries. /// alignment_of template<typename _Tp> struct alignment_of : public integral_constant<std::size_t, __alignof__(_Tp)> { }; - + /// rank template<typename> struct rank : public integral_constant<std::size_t, 0> { }; - + template<typename _Tp, std::size_t _Size> struct rank<_Tp[_Size]> : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; @@ -1483,7 +1483,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename, unsigned _Uint> struct extent : public integral_constant<std::size_t, 0> { }; - + template<typename _Tp, unsigned _Uint, std::size_t _Size> struct extent<_Tp[_Size], _Uint> : public integral_constant<std::size_t, @@ -1559,7 +1559,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> struct remove_const<_Tp const> { typedef _Tp type; }; - + /// remove_volatile template<typename _Tp> struct remove_volatile @@ -1568,7 +1568,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> struct remove_volatile<_Tp volatile> { typedef _Tp type; }; - + /// remove_cv template<typename _Tp> struct remove_cv @@ -1576,17 +1576,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef typename remove_const<typename remove_volatile<_Tp>::type>::type type; }; - + /// add_const template<typename _Tp> struct add_const { typedef _Tp const type; }; - + /// add_volatile template<typename _Tp> struct add_volatile { typedef _Tp volatile type; }; - + /// add_cv template<typename _Tp> struct add_cv @@ -1711,7 +1711,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; public: - typedef typename __match::__type __type; + typedef typename __match::__type __type; }; // Utility for finding the unsigned versions of signed integral types. @@ -1771,7 +1771,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // Select between integral and enum: not possible to be both. - template<typename _Tp, + template<typename _Tp, bool _IsInt = is_integral<_Tp>::value, bool _IsEnum = is_enum<_Tp>::value> class __make_unsigned_selector; @@ -1816,7 +1816,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Primary template. /// make_unsigned template<typename _Tp> - struct make_unsigned + struct make_unsigned { typedef typename __make_unsigned_selector<_Tp>::__type type; }; // Integral, but don't define. @@ -1890,7 +1890,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // Select between integral and enum: not possible to be both. - template<typename _Tp, + template<typename _Tp, bool _IsInt = is_integral<_Tp>::value, bool _IsEnum = is_enum<_Tp>::value> class __make_signed_selector; @@ -1920,7 +1920,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Primary template. /// make_signed template<typename _Tp> - struct make_signed + struct make_signed { typedef typename __make_signed_selector<_Tp>::__type type; }; // Integral, but don't define. @@ -2002,7 +2002,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { typedef typename remove_reference<_Tp>::type* type; }; template<typename _Tp> - struct add_pointer + struct add_pointer : public __add_pointer_helper<_Tp> { }; @@ -2018,11 +2018,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<std::size_t _Len> struct __aligned_storage_msa - { + { union __type { unsigned char __data[_Len]; - struct __attribute__((__aligned__)) { } __align; + struct __attribute__((__aligned__)) { } __align; }; }; @@ -2039,11 +2039,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<std::size_t _Len, std::size_t _Align = __alignof__(typename __aligned_storage_msa<_Len>::__type)> struct aligned_storage - { + { union type { unsigned char __data[_Len]; - struct __attribute__((__aligned__((_Align)))) { } __align; + struct __attribute__((__aligned__((_Align)))) { } __align; }; }; @@ -2096,28 +2096,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Decay trait for arrays and functions, used for perfect forwarding // in make_pair, make_tuple, etc. - template<typename _Up, + template<typename _Up, bool _IsArray = is_array<_Up>::value, - bool _IsFunction = is_function<_Up>::value> + bool _IsFunction = is_function<_Up>::value> struct __decay_selector; // NB: DR 705. - template<typename _Up> + template<typename _Up> struct __decay_selector<_Up, false, false> { typedef typename remove_cv<_Up>::type __type; }; - template<typename _Up> + template<typename _Up> struct __decay_selector<_Up, true, false> { typedef typename remove_extent<_Up>::type* __type; }; - template<typename _Up> + template<typename _Up> struct __decay_selector<_Up, false, true> { typedef typename add_pointer<_Up>::type __type; }; /// decay - template<typename _Tp> - class decay - { + template<typename _Tp> + class decay + { typedef typename remove_reference<_Tp>::type __remove_type; public: @@ -2151,7 +2151,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Primary template. /// Define a member typedef @c type only if a boolean constant is true. template<bool, typename _Tp = void> - struct enable_if + struct enable_if { }; // Partial specialization for true. @@ -2631,7 +2631,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static false_type __test(...); }; - } + } // namespace __swappable_details template<typename _Tp> struct __is_swappable_impl @@ -2657,6 +2657,116 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __is_nothrow_swappable_impl<_Tp>::type { }; +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 +#define __cpp_lib_is_swappable 201603 + /// Metafunctions used for detecting swappable types: p0185r1 + + /// is_swappable + template<typename _Tp> + struct is_swappable + : public __is_swappable_impl<_Tp>::type + { }; + + /// is_nothrow_swappable + template<typename _Tp> + struct is_nothrow_swappable + : public __is_nothrow_swappable_impl<_Tp>::type + { }; + +#if __cplusplus >= 201402L + /// is_swappable_v + template<typename _Tp> + constexpr bool is_swappable_v = is_swappable<_Tp>::value; + + /// is_nothrow_swappable_v + template<typename _Tp> + constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value; +#endif // __cplusplus >= 201402L + + namespace __swappable_with_details { + using std::swap; + + struct __do_is_swappable_with_impl + { + template<typename _Tp, typename _Up, typename + = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), + typename + = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> + static true_type __test(int); + + template<typename, typename> + static false_type __test(...); + }; + + struct __do_is_nothrow_swappable_with_impl + { + template<typename _Tp, typename _Up> + static __bool_constant< + noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) + && + noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) + > __test(int); + + template<typename, typename> + static false_type __test(...); + }; + + } // namespace __swappable_with_details + + template<typename _Tp, typename _Up> + struct __is_swappable_with_impl + : public __swappable_with_details::__do_is_swappable_with_impl + { + typedef decltype(__test<_Tp, _Up>(0)) type; + }; + + // Optimization for the homogenous lvalue case, not required: + template<typename _Tp> + struct __is_swappable_with_impl<_Tp&, _Tp&> + : public __swappable_details::__do_is_swappable_impl + { + typedef decltype(__test<_Tp&>(0)) type; + }; + + template<typename _Tp, typename _Up> + struct __is_nothrow_swappable_with_impl + : public __swappable_with_details::__do_is_nothrow_swappable_with_impl + { + typedef decltype(__test<_Tp, _Up>(0)) type; + }; + + // Optimization for the homogenous lvalue case, not required: + template<typename _Tp> + struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> + : public __swappable_details::__do_is_nothrow_swappable_impl + { + typedef decltype(__test<_Tp&>(0)) type; + }; + + /// is_swappable_with + template<typename _Tp, typename _Up> + struct is_swappable_with + : public __is_swappable_with_impl<_Tp, _Up>::type + { }; + + /// is_nothrow_swappable_with + template<typename _Tp, typename _Up> + struct is_nothrow_swappable_with + : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type + { }; + +#if __cplusplus >= 201402L + /// is_swappable_with_v + template<typename _Tp, typename _Up> + constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value; + + /// is_nothrow_swappable_with_v + template<typename _Tp, typename _Up> + constexpr bool is_nothrow_swappable_with_v = + is_nothrow_swappable_with<_Tp, _Up>::value; +#endif // __cplusplus >= 201402L +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index 480bd5d18ea..1451a91d42a 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -49,7 +49,7 @@ */ /** @file include/utility - * This is a Standard C++ Library header. + * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_UTILITY @@ -150,7 +150,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<class _Tp1, class _Tp2> struct tuple_element<0, std::pair<_Tp1, _Tp2>> { typedef _Tp1 type; }; - + /// Partial specialization for std::pair template<class _Tp1, class _Tp2> struct tuple_element<1, std::pair<_Tp1, _Tp2>> diff --git a/libstdc++-v3/include/std/valarray b/libstdc++-v3/include/std/valarray index 69d96b440a3..3d8e5d6ee28 100644 --- a/libstdc++-v3/include/std/valarray +++ b/libstdc++-v3/include/std/valarray @@ -23,7 +23,7 @@ // <http://www.gnu.org/licenses/>. /** @file include/valarray - * This is a Standard C++ Library header. + * This is a Standard C++ Library header. */ // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr> @@ -45,11 +45,11 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - template<class _Clos, typename _Tp> + template<class _Clos, typename _Tp> class _Expr; - template<typename _Tp1, typename _Tp2> - class _ValArray; + template<typename _Tp1, typename _Tp2> + class _ValArray; template<class _Oper, template<class, class> class _Meta, class _Dom> struct _UnClos; @@ -57,22 +57,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<class _Oper, template<class, class> class _Meta1, template<class, class> class _Meta2, - class _Dom1, class _Dom2> + class _Dom1, class _Dom2> class _BinClos; - template<template<class, class> class _Meta, class _Dom> + template<template<class, class> class _Meta, class _Dom> class _SClos; - template<template<class, class> class _Meta, class _Dom> + template<template<class, class> class _Meta, class _Dom> class _GClos; - - template<template<class, class> class _Meta, class _Dom> + + template<template<class, class> class _Meta, class _Dom> class _IClos; - - template<template<class, class> class _Meta, class _Dom> + + template<template<class, class> class _Meta, class _Dom> class _ValFunClos; - - template<template<class, class> class _Meta, class _Dom> + + template<template<class, class> class _Meta, class _Dom> class _RefFunClos; template<class _Tp> class valarray; // An array of type _Tp @@ -88,7 +88,7 @@ _GLIBCXX_END_NAMESPACE_VERSION #include <bits/valarray_array.h> #include <bits/valarray_before.h> - + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -109,21 +109,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * aliasing that can result from pointer representations. It represents a * one-dimensional array from which different multidimensional subsets can * be accessed and modified. - * + * * @tparam _Tp Type of object in the array. */ - template<class _Tp> + template<class _Tp> class valarray { template<class _Op> - struct _UnaryOp + struct _UnaryOp { typedef typename __fun<_Op, _Tp>::result_type __rt; typedef _Expr<_UnClos<_Op, _ValArray, _Tp>, __rt> _Rt; }; public: typedef _Tp value_type; - + // _lib.valarray.cons_ construct/destroy: /// Construct an empty array. valarray(); @@ -254,7 +254,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // _lib.valarray.access_ element access: /** - * Return a reference to the i'th array element. + * Return a reference to the i'th array element. * * @param __i Index of element to return. * @return Reference to the i'th element. @@ -482,10 +482,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp sum() const; /// Return the minimum element using operator<(). - _Tp min() const; + _Tp min() const; /// Return the maximum element using operator<(). - _Tp max() const; + _Tp max() const; /** * @brief Return a shifted array. @@ -559,14 +559,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION private: size_t _M_size; _Tp* __restrict__ _M_data; - + friend class _Array<_Tp>; }; - + template<typename _Tp> inline const _Tp& valarray<_Tp>::operator[](size_t __i) const - { + { __glibcxx_requires_subscript(__i); return _M_data[__i]; } @@ -574,7 +574,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> inline _Tp& valarray<_Tp>::operator[](size_t __i) - { + { __glibcxx_requires_subscript(__i); return _M_data[__i]; } @@ -605,8 +605,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {} template<typename _Tp> - inline - valarray<_Tp>::valarray(size_t __n) + inline + valarray<_Tp>::valarray(size_t __n) : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) { std::__valarray_default_construct(_M_data, _M_data + __n); } @@ -620,9 +620,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n) : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) - { + { __glibcxx_assert(__p != 0 || __n == 0); - std::__valarray_copy_construct(__p, __p + __n, _M_data); + std::__valarray_copy_construct(__p, __p + __n, _M_data); } template<typename _Tp> @@ -917,7 +917,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif template<class _Tp> - inline size_t + inline size_t valarray<_Tp>::size() const { return _M_size; } @@ -1027,7 +1027,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } std::__valarray_fill_construct(_M_data, _M_data + __n, __c); } - + template<typename _Tp> inline _Tp valarray<_Tp>::min() const @@ -1043,7 +1043,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_assert(_M_size > 0); return *std::max_element(_M_data, _M_data + _M_size); } - + template<class _Tp> inline _Expr<_ValFunClos<_ValArray, _Tp>, _Tp> valarray<_Tp>::apply(_Tp func(_Tp)) const @@ -1130,7 +1130,7 @@ _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, __shift_left) _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right) #undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT - + #define _DEFINE_BINARY_OPERATOR(_Op, _Name) \ template<typename _Tp> \ diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector index a68d892266b..0e9ce754960 100644 --- a/libstdc++-v3/include/std/vector +++ b/libstdc++-v3/include/std/vector @@ -62,7 +62,7 @@ #include <bits/stl_construct.h> #include <bits/stl_uninitialized.h> #include <bits/stl_vector.h> -#include <bits/stl_bvector.h> +#include <bits/stl_bvector.h> #include <bits/range_access.h> #ifndef _GLIBCXX_EXPORT_TEMPLATE diff --git a/libstdc++-v3/include/tr1/hashtable_policy.h b/libstdc++-v3/include/tr1/hashtable_policy.h index 4ee6d45044e..c5cf866b1fe 100644 --- a/libstdc++-v3/include/tr1/hashtable_policy.h +++ b/libstdc++-v3/include/tr1/hashtable_policy.h @@ -420,8 +420,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Prime_rehash_policy:: _M_next_bkt(std::size_t __n) const { - const unsigned long* __p = std::lower_bound(__prime_list, __prime_list - + _S_n_primes, __n); + // Don't include the last prime in the search, so that anything + // higher than the second-to-last prime returns a past-the-end + // iterator that can be dereferenced to get the last prime. + const unsigned long* __p + = std::lower_bound(__prime_list, __prime_list + _S_n_primes - 1, __n); _M_next_resize = static_cast<std::size_t>(__builtin_ceil(*__p * _M_max_load_factor)); return *__p; @@ -434,11 +437,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_bkt_for_elements(std::size_t __n) const { const float __min_bkts = __n / _M_max_load_factor; - const unsigned long* __p = std::lower_bound(__prime_list, __prime_list - + _S_n_primes, __min_bkts); - _M_next_resize = - static_cast<std::size_t>(__builtin_ceil(*__p * _M_max_load_factor)); - return *__p; + return _M_next_bkt(__builtin_ceil(__min_bkts)); } // Finds the smallest prime p such that alpha p > __n_elt + __n_ins. @@ -462,12 +461,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__min_bkts > __n_bkt) { __min_bkts = std::max(__min_bkts, _M_growth_factor * __n_bkt); - const unsigned long* __p = - std::lower_bound(__prime_list, __prime_list + _S_n_primes, - __min_bkts); - _M_next_resize = static_cast<std::size_t> - (__builtin_ceil(*__p * _M_max_load_factor)); - return std::make_pair(true, *__p); + return std::make_pair(true, + _M_next_bkt(__builtin_ceil(__min_bkts))); } else { diff --git a/libstdc++-v3/src/c++11/hashtable_c++0x.cc b/libstdc++-v3/src/c++11/hashtable_c++0x.cc index a5e6520dcdb..ce4961fbd5e 100644 --- a/libstdc++-v3/src/c++11/hashtable_c++0x.cc +++ b/libstdc++-v3/src/c++11/hashtable_c++0x.cc @@ -46,22 +46,38 @@ namespace __detail { // Optimize lookups involving the first elements of __prime_list. // (useful to speed-up, eg, constructors) - static const unsigned char __fast_bkt[12] - = { 2, 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11 }; + static const unsigned char __fast_bkt[13] + = { 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11, 13, 13 }; - if (__n <= 11) + if (__n <= 12) { _M_next_resize = __builtin_ceil(__fast_bkt[__n] * (long double)_M_max_load_factor); return __fast_bkt[__n]; } + // Number of primes (without sentinel). constexpr auto __n_primes = sizeof(__prime_list) / sizeof(unsigned long) - 1; + + // Don't include the last prime in the search, so that anything + // higher than the second-to-last prime returns a past-the-end + // iterator that can be dereferenced to get the last prime. + constexpr auto __last_prime = __prime_list + __n_primes - 1; + + // Look for 'n + 1' to make sure returned value will be greater than n. const unsigned long* __next_bkt = - std::lower_bound(__prime_list + 5, __prime_list + __n_primes, __n); - _M_next_resize = - __builtin_ceil(*__next_bkt * (long double)_M_max_load_factor); + std::lower_bound(__prime_list + 6, __last_prime, __n + 1); + + if (__next_bkt == __last_prime) + // Set next resize to the max value so that we never try to rehash again + // as we already reach the biggest possible bucket number. + // Note that it might result in max_load_factor not being respected. + _M_next_resize = std::size_t(-1); + else + _M_next_resize = + __builtin_ceil(*__next_bkt * (long double)_M_max_load_factor); + return *__next_bkt; } diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc index 5b82088891e..67ed8e6e564 100644 --- a/libstdc++-v3/src/filesystem/ops.cc +++ b/libstdc++-v3/src/filesystem/ops.cc @@ -1084,6 +1084,28 @@ fs::permissions(const path& p, perms prms) void fs::permissions(const path& p, perms prms, error_code& ec) noexcept { + const bool add = is_set(prms, perms::add_perms); + const bool remove = is_set(prms, perms::remove_perms); + if (add && remove) + { + ec = std::make_error_code(std::errc::invalid_argument); + return; + } + + prms &= perms::mask; + + if (add || remove) + { + auto st = status(p, ec); + if (ec) + return; + auto curr = st.permissions(); + if (add) + prms |= curr; + else + prms = curr & ~prms; + } + #if _GLIBCXX_USE_FCHMODAT if (::fchmodat(AT_FDCWD, p.c_str(), static_cast<mode_t>(prms), 0)) #else diff --git a/libstdc++-v3/src/shared/hashtable-aux.cc b/libstdc++-v3/src/shared/hashtable-aux.cc index 081bb1236bc..ec9841e06a1 100644 --- a/libstdc++-v3/src/shared/hashtable-aux.cc +++ b/libstdc++-v3/src/shared/hashtable-aux.cc @@ -25,6 +25,7 @@ namespace __detail { _GLIBCXX_BEGIN_NAMESPACE_VERSION + // The sentinel value is kept only for abi backward compatibility. extern const unsigned long __prime_list[] = // 256 + 1 or 256 + 48 + 1 { 2ul, 3ul, 5ul, 7ul, 11ul, 13ul, 17ul, 19ul, 23ul, 29ul, 31ul, diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc index d10d60d27de..399fd2dae13 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++11" } +// { dg-options "-std=gnu++17" } // { dg-do compile } // Copyright (C) 2015-2016 Free Software Foundation, Inc. @@ -20,8 +20,14 @@ #include <type_traits> +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_nothrow_swappable missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_nothrow_swappable has wrong value" +#endif + namespace std { typedef short test_type; - template struct std::__is_nothrow_swappable<test_type>; + template struct is_nothrow_swappable<test_type>; } diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation_ext.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation_ext.cc new file mode 100644 index 00000000000..fd243004524 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation_ext.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct __is_nothrow_swappable<test_type>; +} diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc index e205c2a6709..a940b636ce7 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++11" } +// { dg-options "-std=gnu++17" } // { dg-do compile } // Copyright (C) 2015-2016 Free Software Foundation, Inc. @@ -20,11 +20,16 @@ #include <type_traits> +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_nothrow_swappable missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_nothrow_swappable has wrong value" +#endif void test01() { // Check for required typedefs - typedef std::__is_nothrow_swappable<int> test_type; + typedef std::is_nothrow_swappable<int> test_type; typedef test_type::value_type value_type; typedef test_type::type type; typedef test_type::type::value_type type_value_type; diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/typedefs_ext.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/typedefs_ext.cc new file mode 100644 index 00000000000..fa23a745f6c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/requirements/typedefs_ext.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> + +void test01() +{ + // Check for required typedefs + typedef std::__is_nothrow_swappable<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.cc index 5f93891b8a5..824734553d7 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++11" } +// { dg-options "-std=gnu++17" } // { dg-do compile } // Copyright (C) 2015-2016 Free Software Foundation, Inc. @@ -18,218 +18,5 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -#include <type_traits> -#include <testsuite_tr1.h> -#include <utility> -#include <array> -#include <tuple> -#include <queue> -#include <stack> - -namespace funny { - struct F {}; - void swap(F&, F&) = delete; - void swap(F(&)[5], F(&)[5]) noexcept; - void swap(F(&)[6], F(&)[6]); - struct A {}; - void swap(A&, A&) noexcept(false); -} -namespace std { - template<> - void swap<funny::A>(funny::A&, funny::A&) noexcept - { - } - - template<> - void swap<funny::A>(funny::A(&)[3], funny::A(&)[3]) noexcept(false) - { - } -} -namespace ns1 { - struct SwapThrow {}; - void swap(SwapThrow&, SwapThrow&); - void swap(SwapThrow(&)[3], SwapThrow(&)[3]) noexcept; -} - -namespace ns2 { - struct SwapThrow { - SwapThrow() noexcept = default; - SwapThrow(const SwapThrow&) noexcept(false); - SwapThrow& operator=(const SwapThrow&) noexcept(false); - }; -} - -namespace ns3 { - struct SwapNoThrow { - SwapNoThrow() noexcept = default; - SwapNoThrow(const SwapNoThrow&) noexcept(false); - SwapNoThrow& operator =(const SwapNoThrow&) noexcept(false); - }; - void swap(SwapNoThrow&, SwapNoThrow&) noexcept; -} - -namespace ns4 { - struct SwapNoThrow {}; -} - -namespace ns5 { - struct SwapThrow { - SwapThrow() noexcept = default; - SwapThrow(SwapThrow&&) noexcept; - SwapThrow& operator=(const SwapThrow&) noexcept(false); - }; -} -void test01() -{ - using std::__is_nothrow_swappable; - using namespace __gnu_test; - // Positive tests. - static_assert(test_property<__is_nothrow_swappable, int>(true), ""); - static_assert(test_property<__is_nothrow_swappable, bool>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - decltype(nullptr)>(true), ""); - static_assert(test_property<__is_nothrow_swappable, int&>(true), ""); - static_assert(test_property<__is_nothrow_swappable, int&&>(true), ""); - static_assert(test_property<__is_nothrow_swappable, int[1]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, int[1][2]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, int[1][2][3]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, funny::F[5]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, EnumType>(true), ""); - static_assert(test_property<__is_nothrow_swappable, PODType>(true), ""); - static_assert(test_property<__is_nothrow_swappable, UnionType>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - construct::SE>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - construct::Empty>(true), ""); - static_assert(test_property<__is_nothrow_swappable, void*>(true), ""); - static_assert(test_property<__is_nothrow_swappable, void(*)()>(true), ""); - static_assert(test_property<__is_nothrow_swappable, int const*>(true), ""); - static_assert(test_property<__is_nothrow_swappable, ClassType*>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - int ClassType::*>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - void (ClassType::*)()>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - int (ClassType::*)() const volatile>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - ns1::SwapThrow[3]>(true), ""); - static_assert(!noexcept(std::swap(std::declval<ns1::SwapThrow(&)[3]>(), - std::declval<ns1::SwapThrow(&)[3]>())), - ""); - static_assert(test_property<__is_nothrow_swappable, - ns3::SwapNoThrow>(true), ""); - static_assert(!noexcept(std::swap(std::declval<ns3::SwapNoThrow&>(), - std::declval<ns3::SwapNoThrow&>())), ""); - static_assert(test_property<__is_nothrow_swappable, - ns3::SwapNoThrow[1]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - ns3::SwapNoThrow[3]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - ns3::SwapNoThrow[2][3][4]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - ns4::SwapNoThrow>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - ns4::SwapNoThrow[1]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - ns4::SwapNoThrow[3]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - ns4::SwapNoThrow[2][3][4]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::pair<int, int>>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::pair<int, int>[1]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::pair<int, int>[1][2]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::tuple<int>>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::tuple<int>[1]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::tuple<int>[1][2]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::tuple<>>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::tuple<>[1]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::tuple<>[1][2]>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::array<int, 1>>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::queue<int>>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::priority_queue<int>>(true), ""); - static_assert(test_property<__is_nothrow_swappable, - std::stack<int>>(true), ""); - // Negative tests. - static_assert(test_property<__is_nothrow_swappable, void>(false), ""); - static_assert(test_property<__is_nothrow_swappable, const void>(false), ""); - static_assert(test_property<__is_nothrow_swappable, void()>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - void() const>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - void() volatile>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - void() const volatile>(false), ""); - static_assert(test_property<__is_nothrow_swappable, const int>(false), ""); - static_assert(test_property<__is_nothrow_swappable, const bool>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - const int[1]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - const int[1][2]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - const int[1][2][3]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, int[]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, const int[]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, int[][1]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - const funny::F[5]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - construct::Abstract>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - construct::DelCopy>(false), ""); - static_assert(test_property<__is_nothrow_swappable, funny::F>(false), ""); - static_assert(test_property<__is_nothrow_swappable, funny::F[1]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - funny::F[1][2]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - funny::F[1][2][3]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, funny::F[6]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, funny::A>(false), ""); - static_assert(noexcept(std::swap(std::declval<funny::A&>(), - std::declval<funny::A&>())), ""); - static_assert(test_property<__is_nothrow_swappable, funny::A[3]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns1::SwapThrow>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns1::SwapThrow[1]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns1::SwapThrow[3][2]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns1::SwapThrow[2][3][4]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns2::SwapThrow>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns2::SwapThrow[1]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns2::SwapThrow[2][3][4]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns5::SwapThrow>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns5::SwapThrow[1]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ns5::SwapThrow[2][3][4]>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - ThrowCopyConsClass>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - std::pair<ThrowCopyConsClass, ThrowCopyConsClass>>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - std::tuple<ThrowCopyConsClass>>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - std::array<ThrowCopyConsClass, 1>>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - std::queue<ThrowCopyConsClass>>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - std::priority_queue<ThrowCopyConsClass>>(false), ""); - static_assert(test_property<__is_nothrow_swappable, - std::stack<ThrowCopyConsClass>>(false), ""); -} +#define test_std_is_nothrow_swappable +#include "./value.h" diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.h b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.h new file mode 100644 index 00000000000..1b374f0bade --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value.h @@ -0,0 +1,297 @@ +// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_tr1.h> +#include <utility> +#include <array> +#include <tuple> +#include <queue> +#include <stack> + +#if defined(test_std_is_nothrow_swappable) +# ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_nothrow_swappable missing" +# elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_nothrow_swappable has wrong value" +# endif +// Test std::is_nothrow_swappable: +template<class T> +using is_nothrow_swappable = std::is_nothrow_swappable<T>; +#elif defined(test_std_is_nothrow_swappable_ext) +// Test our __is_nothrow_swappable extension: +template<class T> +using is_nothrow_swappable = std::__is_nothrow_swappable<T>; +#else +# error "Either test_std_is_nothrow_swappable or " \ + "test_std_is_nothrow_swappable_ext need to be defined" +#endif + +namespace funny { + struct F {}; + void swap(F&, F&) = delete; + void swap(F(&)[5], F(&)[5]) noexcept; + void swap(F(&)[6], F(&)[6]); + struct A {}; + void swap(A&, A&) noexcept(false); +} +namespace std { + template<> + void swap<funny::A>(funny::A&, funny::A&) noexcept + { + } + + template<> + void swap<funny::A>(funny::A(&)[3], funny::A(&)[3]) noexcept(false) + { + } +} +namespace ns1 { + struct SwapThrow {}; + void swap(SwapThrow&, SwapThrow&); + void swap(SwapThrow(&)[3], SwapThrow(&)[3]) noexcept; +} + +namespace ns2 { + struct SwapThrow { + SwapThrow() noexcept = default; + SwapThrow(const SwapThrow&) noexcept(false); + SwapThrow& operator=(const SwapThrow&) noexcept(false); + }; +} + +namespace ns3 { + struct SwapNoThrow { + SwapNoThrow() noexcept = default; + SwapNoThrow(const SwapNoThrow&) noexcept(false); + SwapNoThrow& operator =(const SwapNoThrow&) noexcept(false); + }; + void swap(SwapNoThrow&, SwapNoThrow&) noexcept; +} + +namespace ns4 { + struct SwapNoThrow {}; +} + +namespace ns5 { + struct SwapThrow { + SwapThrow() noexcept = default; + SwapThrow(SwapThrow&&) noexcept; + SwapThrow& operator=(const SwapThrow&) noexcept(false); + }; +} + +namespace comps { + struct CompareNoThrowCopyable + { + template<class T> + bool operator()(const T&, const T&) const + { return false; } + }; + + struct CompareNonCopyable + { + CompareNonCopyable() = default; + CompareNonCopyable(const CompareNonCopyable&) = delete; + CompareNonCopyable& operator=(const CompareNonCopyable&) noexcept; + + template<class T> + bool operator()(const T&, const T&) const + { return false; } + }; + + struct CompareThrowCopyable + { + CompareThrowCopyable() = default; + CompareThrowCopyable(const CompareThrowCopyable&) noexcept(false); + CompareThrowCopyable& operator=(const CompareThrowCopyable&); + + template<class T> + bool operator()(const T&, const T&) const + { return false; } + }; +} + +void test01() +{ + using namespace __gnu_test; + // Positive tests. + static_assert(test_property<is_nothrow_swappable, int>(true), ""); + static_assert(test_property<is_nothrow_swappable, bool>(true), ""); + static_assert(test_property<is_nothrow_swappable, + decltype(nullptr)>(true), ""); + static_assert(test_property<is_nothrow_swappable, int&>(true), ""); + static_assert(test_property<is_nothrow_swappable, int&&>(true), ""); + static_assert(test_property<is_nothrow_swappable, int[1]>(true), ""); + static_assert(test_property<is_nothrow_swappable, int[1][2]>(true), ""); + static_assert(test_property<is_nothrow_swappable, int[1][2][3]>(true), ""); + static_assert(test_property<is_nothrow_swappable, funny::F[5]>(true), ""); + static_assert(test_property<is_nothrow_swappable, EnumType>(true), ""); + static_assert(test_property<is_nothrow_swappable, PODType>(true), ""); + static_assert(test_property<is_nothrow_swappable, UnionType>(true), ""); + static_assert(test_property<is_nothrow_swappable, + construct::SE>(true), ""); + static_assert(test_property<is_nothrow_swappable, + construct::Empty>(true), ""); + static_assert(test_property<is_nothrow_swappable, void*>(true), ""); + static_assert(test_property<is_nothrow_swappable, void(*)()>(true), ""); + static_assert(test_property<is_nothrow_swappable, int const*>(true), ""); + static_assert(test_property<is_nothrow_swappable, ClassType*>(true), ""); + static_assert(test_property<is_nothrow_swappable, + int ClassType::*>(true), ""); + static_assert(test_property<is_nothrow_swappable, + void (ClassType::*)()>(true), ""); + static_assert(test_property<is_nothrow_swappable, + int (ClassType::*)() const volatile>(true), ""); + static_assert(test_property<is_nothrow_swappable, + ns1::SwapThrow[3]>(true), ""); + static_assert(!noexcept(std::swap(std::declval<ns1::SwapThrow(&)[3]>(), + std::declval<ns1::SwapThrow(&)[3]>())), + ""); + static_assert(test_property<is_nothrow_swappable, + ns3::SwapNoThrow>(true), ""); + static_assert(!noexcept(std::swap(std::declval<ns3::SwapNoThrow&>(), + std::declval<ns3::SwapNoThrow&>())), ""); + static_assert(test_property<is_nothrow_swappable, + ns3::SwapNoThrow[1]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + ns3::SwapNoThrow[3]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + ns3::SwapNoThrow[2][3][4]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + ns4::SwapNoThrow>(true), ""); + static_assert(test_property<is_nothrow_swappable, + ns4::SwapNoThrow[1]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + ns4::SwapNoThrow[3]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + ns4::SwapNoThrow[2][3][4]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::pair<int, int>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::pair<int, int>[1]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::pair<int, int>[1][2]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::tuple<int>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::tuple<int>[1]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::tuple<int>[1][2]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::tuple<>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::tuple<>[1]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::tuple<>[1][2]>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::array<int, 1>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::array<int, 0>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::array<construct::DelCopy, 0>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::array<ns1::SwapThrow, 0>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::queue<int>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::priority_queue<int>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::stack<int>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::priority_queue<int, std::vector<int>, + comps::CompareNoThrowCopyable>>(true), ""); + + // Negative tests. + static_assert(test_property<is_nothrow_swappable, void>(false), ""); + static_assert(test_property<is_nothrow_swappable, const void>(false), ""); + static_assert(test_property<is_nothrow_swappable, void()>(false), ""); + static_assert(test_property<is_nothrow_swappable, + void() const>(false), ""); + static_assert(test_property<is_nothrow_swappable, + void() volatile>(false), ""); + static_assert(test_property<is_nothrow_swappable, + void() const volatile>(false), ""); + static_assert(test_property<is_nothrow_swappable, const int>(false), ""); + static_assert(test_property<is_nothrow_swappable, const bool>(false), ""); + static_assert(test_property<is_nothrow_swappable, + const int[1]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + const int[1][2]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + const int[1][2][3]>(false), ""); + static_assert(test_property<is_nothrow_swappable, int[]>(false), ""); + static_assert(test_property<is_nothrow_swappable, const int[]>(false), ""); + static_assert(test_property<is_nothrow_swappable, int[][1]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + const funny::F[5]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + construct::Abstract>(false), ""); + static_assert(test_property<is_nothrow_swappable, + construct::DelCopy>(false), ""); + static_assert(test_property<is_nothrow_swappable, funny::F>(false), ""); + static_assert(test_property<is_nothrow_swappable, funny::F[1]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + funny::F[1][2]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + funny::F[1][2][3]>(false), ""); + static_assert(test_property<is_nothrow_swappable, funny::F[6]>(false), ""); + static_assert(test_property<is_nothrow_swappable, funny::A>(false), ""); + static_assert(noexcept(std::swap(std::declval<funny::A&>(), + std::declval<funny::A&>())), ""); + static_assert(test_property<is_nothrow_swappable, funny::A[3]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns1::SwapThrow>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns1::SwapThrow[1]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns1::SwapThrow[3][2]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns1::SwapThrow[2][3][4]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns2::SwapThrow>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns2::SwapThrow[1]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns2::SwapThrow[2][3][4]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns5::SwapThrow>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns5::SwapThrow[1]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ns5::SwapThrow[2][3][4]>(false), ""); + static_assert(test_property<is_nothrow_swappable, + ThrowCopyConsClass>(false), ""); + static_assert(test_property<is_nothrow_swappable, + std::pair<ThrowCopyConsClass, ThrowCopyConsClass>>(false), ""); + static_assert(test_property<is_nothrow_swappable, + std::tuple<ThrowCopyConsClass>>(false), ""); + static_assert(test_property<is_nothrow_swappable, + std::array<ThrowCopyConsClass, 1>>(false), ""); + static_assert(test_property<is_nothrow_swappable, + std::queue<ThrowCopyConsClass>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::priority_queue<ThrowCopyConsClass>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::stack<ThrowCopyConsClass>>(true), ""); + static_assert(test_property<is_nothrow_swappable, + std::priority_queue<int, std::vector<int>, + comps::CompareNonCopyable>>(false), ""); + static_assert(test_property<is_nothrow_swappable, + std::priority_queue<int, std::vector<int>, + comps::CompareThrowCopyable>>(false), ""); +} diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value_ext.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value_ext.cc new file mode 100644 index 00000000000..daf5a915970 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/value_ext.cc @@ -0,0 +1,22 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#define test_std_is_nothrow_swappable_ext +#include "./value.h" diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..e6c8effb1a9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/requirements/explicit_instantiation.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> + +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_nothrow_swappable_with missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_nothrow_swappable_with has wrong value" +#endif + +namespace std +{ + typedef short test_type; + typedef double test_type_2; + template struct is_nothrow_swappable_with<test_type, test_type>; + template struct is_nothrow_swappable_with<test_type, test_type_2>; + template struct is_nothrow_swappable_with<test_type_2, test_type_2>; +} diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc new file mode 100644 index 00000000000..2a68a8315e4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> + +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_nothrow_swappable_with missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_nothrow_swappable_with has wrong value" +#endif + +void test01() +{ + // Check for required typedefs + typedef std::is_nothrow_swappable_with<int, int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/value.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/value.cc new file mode 100644 index 00000000000..f7cd254a472 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/value.cc @@ -0,0 +1,145 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_tr1.h> + +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_nothrow_swappable_with missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_nothrow_swappable_with has wrong value" +#endif + +namespace funny { + struct T0 {}; + + void swap(T0, T0) noexcept; + + struct T1 + { + friend void swap(T1, T1) noexcept; + }; + + struct T2 {}; + struct T3 {}; + + void swap(T2, T3) noexcept; + void swap(T3, T2) noexcept; + + struct T4 { operator T0() const noexcept; }; + + struct F0 {}; + + void swap(F0, F0) = delete; + + struct F1 {}; + + void swap(F1, F1); + + struct F2 {}; + + void swap(F0, F2) noexcept; + void swap(F2, F0); + + struct F3 + { + friend void swap(F3, F3) = delete; + }; + + struct F4 + { + friend void swap(F4, F4); + }; + + struct F5 { operator T0() const; }; + + struct BoolLike {}; + + void swap(BoolLike, bool&) noexcept; + void swap(bool&, BoolLike) noexcept; + + struct BoolLikeErr {}; + + void swap(BoolLikeErr, bool&); + void swap(bool&, BoolLikeErr) noexcept; +} + +void test01() +{ + using std::is_nothrow_swappable_with; + using namespace __gnu_test; + // Positive tests. + static_assert(test_property<is_nothrow_swappable_with, int&, int&>(true), + ""); + static_assert(test_property<is_nothrow_swappable_with, funny::T0, + funny::T0>(true), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::T0, + const funny::T0>(true), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::T1, + funny::T1>(true), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::T1, + const funny::T1>(true), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::T2, + funny::T3>(true), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::T3, + funny::T2>(true), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::T0, + funny::T4>(true), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::T4, + funny::T0>(true), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::BoolLike, + bool&>(true), ""); + static_assert(test_property<is_nothrow_swappable_with, const funny::BoolLike, + bool&>(true), ""); + + // Negative tests. + static_assert(test_property<is_nothrow_swappable_with, const int&, + const int&>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, int&, + unsigned&>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F0, + funny::F0>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F0, + const funny::F0>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F1, + funny::F1>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F1, + const funny::F1>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F0, + funny::F2>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F2, + funny::F0>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F3, + funny::F3>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F3, + const funny::F3>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F4, + funny::F4>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F4, + const funny::F4>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::T0, + funny::F5>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::F5, + funny::T0>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, funny::BoolLikeErr, + bool&>(false), ""); + static_assert(test_property<is_nothrow_swappable_with, + const funny::BoolLikeErr, bool&>(false), ""); +} diff --git a/libstdc++-v3/testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc index c3f93435290..9ba5a525f24 100644 --- a/libstdc++-v3/testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc @@ -1,7 +1,7 @@ -// { dg-options "-std=gnu++11" } +// { dg-options "-std=gnu++17" } // { dg-do compile } -// Copyright (C) 2015 Free Software Foundation, Inc. +// Copyright (C) 2015-2016 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -20,8 +20,14 @@ #include <type_traits> +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_swappable missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_swappable has wrong value" +#endif + namespace std { typedef short test_type; - template struct std::__is_swappable<test_type>; + template struct is_swappable<test_type>; } diff --git a/libstdc++-v3/testsuite/20_util/is_swappable/requirements/explicit_instantiation_ext.cc b/libstdc++-v3/testsuite/20_util/is_swappable/requirements/explicit_instantiation_ext.cc new file mode 100644 index 00000000000..7afe3171608 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_swappable/requirements/explicit_instantiation_ext.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct __is_swappable<test_type>; +} diff --git a/libstdc++-v3/testsuite/20_util/is_swappable/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_swappable/requirements/typedefs.cc index a1e289bb01f..feed51affcb 100644 --- a/libstdc++-v3/testsuite/20_util/is_swappable/requirements/typedefs.cc +++ b/libstdc++-v3/testsuite/20_util/is_swappable/requirements/typedefs.cc @@ -1,7 +1,7 @@ -// { dg-options "-std=gnu++11" } +// { dg-options "-std=gnu++17" } // { dg-do compile } -// Copyright (C) 2015 Free Software Foundation, Inc. +// Copyright (C) 2015-2016 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -20,10 +20,16 @@ #include <type_traits> +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_swappable missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_swappable has wrong value" +#endif + void test01() { // Check for required typedefs - typedef std::__is_swappable<int> test_type; + typedef std::is_swappable<int> test_type; typedef test_type::value_type value_type; typedef test_type::type type; typedef test_type::type::value_type type_value_type; diff --git a/libstdc++-v3/testsuite/20_util/is_swappable/requirements/typedefs_ext.cc b/libstdc++-v3/testsuite/20_util/is_swappable/requirements/typedefs_ext.cc new file mode 100644 index 00000000000..8b697e6ecb3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_swappable/requirements/typedefs_ext.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> + +void test01() +{ + // Check for required typedefs + typedef std::__is_swappable<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_swappable/value.cc b/libstdc++-v3/testsuite/20_util/is_swappable/value.cc index d594cf652a5..eb3a1d2b7a1 100644 --- a/libstdc++-v3/testsuite/20_util/is_swappable/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_swappable/value.cc @@ -1,7 +1,7 @@ -// { dg-options "-std=gnu++11" } +// { dg-options "-std=gnu++17" } // { dg-do compile } -// Copyright (C) 2015 Free Software Foundation, Inc. +// Copyright (C) 2015-2016 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -18,168 +18,5 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -#include <type_traits> -#include <testsuite_tr1.h> -#include <utility> -#include <array> -#include <tuple> -#include <queue> -#include <stack> - -namespace funny { - struct F {}; - void swap(F&, F&) = delete; - void swap(F(&)[5], F(&)[5]); - - struct F2 - { - friend void swap(F2&, F2&) = delete; - }; - - struct F3 - { - friend void swap(F3&, F3) {} - }; -} -void test01() -{ - using std::__is_swappable; - using namespace __gnu_test; - // Positive tests. - static_assert(test_property<__is_swappable, int>(true), ""); - static_assert(test_property<__is_swappable, bool>(true), ""); - static_assert(test_property<__is_swappable, decltype(nullptr)>(true), ""); - static_assert(test_property<__is_swappable, int&>(true), ""); - static_assert(test_property<__is_swappable, int&&>(true), ""); - static_assert(test_property<__is_swappable, int[1]>(true), ""); - static_assert(test_property<__is_swappable, int[1][2]>(true), ""); - static_assert(test_property<__is_swappable, int[1][2][3]>(true), ""); - static_assert(test_property<__is_swappable, int(&)[1]>(true), ""); - static_assert(test_property<__is_swappable, funny::F[5]>(true), ""); - static_assert(test_property<__is_swappable, funny::F3>(true), ""); - static_assert(test_property<__is_swappable, funny::F3[1]>(true), ""); - static_assert(test_property<__is_swappable, funny::F3[1][2]>(true), ""); - static_assert(test_property<__is_swappable, funny::F3[1][2][3]>(true), ""); - static_assert(test_property<__is_swappable, - ThrowCopyConsClass>(true), ""); - static_assert(test_property<__is_swappable, EnumType>(true), ""); - static_assert(test_property<__is_swappable, PODType>(true), ""); - static_assert(test_property<__is_swappable, UnionType>(true), ""); - static_assert(test_property<__is_swappable, construct::SE>(true), ""); - static_assert(test_property<__is_swappable, construct::Empty>(true), ""); - static_assert(test_property<__is_swappable, void*>(true), ""); - static_assert(test_property<__is_swappable, int const*>(true), ""); - static_assert(test_property<__is_swappable, ClassType*>(true), ""); - static_assert(test_property<__is_swappable, int ClassType::*>(true), ""); - static_assert(test_property<__is_swappable, - void (ClassType::*)()>(true), ""); - static_assert(test_property<__is_swappable, - construct::Nontrivial>(true), ""); - static_assert(test_property<__is_swappable, construct::Any>(true), ""); - static_assert(test_property<__is_swappable, construct::nAny>(true), ""); - static_assert(test_property<__is_swappable, - std::pair<int, int>>(true), ""); - static_assert(test_property<__is_swappable, - std::pair<int, int>[1]>(true), ""); - static_assert(test_property<__is_swappable, - std::pair<int, int>[1][2]>(true), ""); - static_assert(test_property<__is_swappable, - std::pair<int, int>[1][2][3]>(true), ""); - static_assert(test_property<__is_swappable, - std::pair<construct::Nontrivial, construct::Nontrivial>>(true), ""); - static_assert(test_property<__is_swappable, - std::tuple<int>>(true), ""); - static_assert(test_property<__is_swappable, - std::tuple<int>[1]>(true), ""); - static_assert(test_property<__is_swappable, - std::tuple<int>[1][2]>(true), ""); - static_assert(test_property<__is_swappable, - std::tuple<int>[1][2][3]>(true), ""); - static_assert(test_property<__is_swappable, - std::tuple<>>(true), ""); - static_assert(test_property<__is_swappable, - std::tuple<>[1]>(true), ""); - static_assert(test_property<__is_swappable, - std::tuple<>[1][2]>(true), ""); - static_assert(test_property<__is_swappable, - std::tuple<>[1][2][3]>(true), ""); - static_assert(test_property<__is_swappable, - std::tuple<construct::Nontrivial>>(true), ""); - static_assert(test_property<__is_swappable, - std::array<int, 1>>(true), ""); - static_assert(test_property<__is_swappable, - std::array<int, 1>[1]>(true), ""); - static_assert(test_property<__is_swappable, - std::array<int, 1>[1][2]>(true), ""); - static_assert(test_property<__is_swappable, - std::array<int, 1>[1][2][3]>(true), ""); - static_assert(test_property<__is_swappable, - std::array<construct::Nontrivial, 1>>(true), ""); - static_assert(test_property<__is_swappable, - std::queue<int>>(true), ""); - static_assert(test_property<__is_swappable, - std::queue<int>[1]>(true), ""); - static_assert(test_property<__is_swappable, - std::queue<int>[1][2]>(true), ""); - static_assert(test_property<__is_swappable, - std::queue<int>[1][2][3]>(true), ""); - static_assert(test_property<__is_swappable, - std::queue<construct::Nontrivial>>(true), ""); - static_assert(test_property<__is_swappable, - std::priority_queue<int>>(true), ""); - static_assert(test_property<__is_swappable, - std::priority_queue<int>[1]>(true), ""); - static_assert(test_property<__is_swappable, - std::priority_queue<int>[1][2]>(true), ""); - static_assert(test_property<__is_swappable, - std::priority_queue<int>[1][2][3]>(true), ""); - static_assert(test_property<__is_swappable, - std::priority_queue<construct::Nontrivial>>(true), ""); - static_assert(test_property<__is_swappable, - std::stack<int>>(true), ""); - static_assert(test_property<__is_swappable, - std::stack<int>[1]>(true), ""); - static_assert(test_property<__is_swappable, - std::stack<int>[1][2]>(true), ""); - static_assert(test_property<__is_swappable, - std::stack<int>[1][2][3]>(true), ""); - static_assert(test_property<__is_swappable, - std::stack<construct::Nontrivial>>(true), ""); - // Negative tests. - static_assert(test_property<__is_swappable, void>(false), ""); - static_assert(test_property<__is_swappable, const void>(false), ""); - static_assert(test_property<__is_swappable, void()>(false), ""); - static_assert(test_property<__is_swappable, void() const>(false), ""); - static_assert(test_property<__is_swappable, void() volatile>(false), ""); - static_assert(test_property<__is_swappable, - void() const volatile>(false), ""); - static_assert(test_property<__is_swappable, const int>(false), ""); - static_assert(test_property<__is_swappable, const bool>(false), ""); - static_assert(test_property<__is_swappable, int[]>(false), ""); - static_assert(test_property<__is_swappable, const int[]>(false), ""); - static_assert(test_property<__is_swappable, int[][1]>(false), ""); - static_assert(test_property<__is_swappable, const int[1]>(false), ""); - static_assert(test_property<__is_swappable, const int[1][2]>(false), ""); - static_assert(test_property<__is_swappable, const int[1][2][3]>(false), ""); - static_assert(test_property<__is_swappable, construct::DelCopy>(false), ""); - static_assert(test_property<__is_swappable, - construct::Abstract>(false), ""); - static_assert(test_property<__is_swappable, - construct::NontrivialUnion>(false), ""); - static_assert(test_property<__is_swappable, funny::F>(false), ""); - static_assert(test_property<__is_swappable, funny::F[1]>(false), ""); - static_assert(test_property<__is_swappable, funny::F[1][2]>(false), ""); - static_assert(test_property<__is_swappable, funny::F[1][2][3]>(false), ""); - static_assert(test_property<__is_swappable, funny::F[4]>(false), ""); - static_assert(test_property<__is_swappable, construct::DelCopy>(false), ""); - static_assert(test_property<__is_swappable, - DeletedCopyAssignClass>(false), ""); - static_assert(test_property<__is_swappable, - DeletedMoveAssignClass>(false), ""); - static_assert(test_property<__is_swappable, funny::F2>(false), ""); - static_assert(test_property<__is_swappable, funny::F2[1]>(false), ""); - static_assert(test_property<__is_swappable, funny::F2[1][2]>(false), ""); - static_assert(test_property<__is_swappable, funny::F2[1][2][3]>(false), ""); - static_assert(test_property<__is_swappable, funny::F2[4]>(false), ""); - static_assert(test_property<__is_swappable, funny::F2[5]>(false), ""); -} +#define test_std_is_swappable +#include "./value.h" diff --git a/libstdc++-v3/testsuite/20_util/is_swappable/value.h b/libstdc++-v3/testsuite/20_util/is_swappable/value.h new file mode 100644 index 00000000000..0e924d1f32f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_swappable/value.h @@ -0,0 +1,203 @@ +// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_tr1.h> +#include <utility> +#include <array> +#include <tuple> +#include <queue> +#include <stack> + +#if defined(test_std_is_swappable) +# ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_swappable missing" +# elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_swappable has wrong value" +# endif +// Test std::is_swappable: +template<class T> +using is_swappable = std::is_swappable<T>; +#elif defined(test_std_is_swappable_ext) +// Test our __is_swappable extension: +template<class T> +using is_swappable = std::__is_swappable<T>; +#else +# error "Either test_std_is_swappable or test_std_is_swappable_ext" \ + "need to be defined" +#endif + +namespace funny { + struct F {}; + void swap(F&, F&) = delete; + void swap(F(&)[5], F(&)[5]); + + struct F2 + { + friend void swap(F2&, F2&) = delete; + }; + + struct F3 + { + friend void swap(F3&, F3) {} + }; +} +void test01() +{ + using namespace __gnu_test; + // Positive tests. + static_assert(test_property<is_swappable, int>(true), ""); + static_assert(test_property<is_swappable, bool>(true), ""); + static_assert(test_property<is_swappable, decltype(nullptr)>(true), ""); + static_assert(test_property<is_swappable, int&>(true), ""); + static_assert(test_property<is_swappable, int&&>(true), ""); + static_assert(test_property<is_swappable, int[1]>(true), ""); + static_assert(test_property<is_swappable, int[1][2]>(true), ""); + static_assert(test_property<is_swappable, int[1][2][3]>(true), ""); + static_assert(test_property<is_swappable, int(&)[1]>(true), ""); + static_assert(test_property<is_swappable, funny::F[5]>(true), ""); + static_assert(test_property<is_swappable, funny::F3>(true), ""); + static_assert(test_property<is_swappable, funny::F3[1]>(true), ""); + static_assert(test_property<is_swappable, funny::F3[1][2]>(true), ""); + static_assert(test_property<is_swappable, funny::F3[1][2][3]>(true), ""); + static_assert(test_property<is_swappable, + ThrowCopyConsClass>(true), ""); + static_assert(test_property<is_swappable, EnumType>(true), ""); + static_assert(test_property<is_swappable, PODType>(true), ""); + static_assert(test_property<is_swappable, UnionType>(true), ""); + static_assert(test_property<is_swappable, construct::SE>(true), ""); + static_assert(test_property<is_swappable, construct::Empty>(true), ""); + static_assert(test_property<is_swappable, void*>(true), ""); + static_assert(test_property<is_swappable, int const*>(true), ""); + static_assert(test_property<is_swappable, ClassType*>(true), ""); + static_assert(test_property<is_swappable, int ClassType::*>(true), ""); + static_assert(test_property<is_swappable, + void (ClassType::*)()>(true), ""); + static_assert(test_property<is_swappable, + construct::Nontrivial>(true), ""); + static_assert(test_property<is_swappable, construct::Any>(true), ""); + static_assert(test_property<is_swappable, construct::nAny>(true), ""); + static_assert(test_property<is_swappable, + std::pair<int, int>>(true), ""); + static_assert(test_property<is_swappable, + std::pair<int, int>[1]>(true), ""); + static_assert(test_property<is_swappable, + std::pair<int, int>[1][2]>(true), ""); + static_assert(test_property<is_swappable, + std::pair<int, int>[1][2][3]>(true), ""); + static_assert(test_property<is_swappable, + std::pair<construct::Nontrivial, construct::Nontrivial>>(true), ""); + static_assert(test_property<is_swappable, + std::tuple<int>>(true), ""); + static_assert(test_property<is_swappable, + std::tuple<int>[1]>(true), ""); + static_assert(test_property<is_swappable, + std::tuple<int>[1][2]>(true), ""); + static_assert(test_property<is_swappable, + std::tuple<int>[1][2][3]>(true), ""); + static_assert(test_property<is_swappable, + std::tuple<>>(true), ""); + static_assert(test_property<is_swappable, + std::tuple<>[1]>(true), ""); + static_assert(test_property<is_swappable, + std::tuple<>[1][2]>(true), ""); + static_assert(test_property<is_swappable, + std::tuple<>[1][2][3]>(true), ""); + static_assert(test_property<is_swappable, + std::tuple<construct::Nontrivial>>(true), ""); + static_assert(test_property<is_swappable, + std::array<int, 1>>(true), ""); + static_assert(test_property<is_swappable, + std::array<int, 1>[1]>(true), ""); + static_assert(test_property<is_swappable, + std::array<int, 1>[1][2]>(true), ""); + static_assert(test_property<is_swappable, + std::array<int, 1>[1][2][3]>(true), ""); + static_assert(test_property<is_swappable, + std::array<construct::Nontrivial, 1>>(true), ""); + static_assert(test_property<is_swappable, + std::array<int, 0>>(true), ""); + static_assert(test_property<is_swappable, + std::array<construct::DelCopy, 0>>(true), ""); + static_assert(test_property<is_swappable, + std::queue<int>>(true), ""); + static_assert(test_property<is_swappable, + std::queue<int>[1]>(true), ""); + static_assert(test_property<is_swappable, + std::queue<int>[1][2]>(true), ""); + static_assert(test_property<is_swappable, + std::queue<int>[1][2][3]>(true), ""); + static_assert(test_property<is_swappable, + std::queue<construct::Nontrivial>>(true), ""); + static_assert(test_property<is_swappable, + std::priority_queue<int>>(true), ""); + static_assert(test_property<is_swappable, + std::priority_queue<int>[1]>(true), ""); + static_assert(test_property<is_swappable, + std::priority_queue<int>[1][2]>(true), ""); + static_assert(test_property<is_swappable, + std::priority_queue<int>[1][2][3]>(true), ""); + static_assert(test_property<is_swappable, + std::priority_queue<construct::Nontrivial>>(true), ""); + static_assert(test_property<is_swappable, + std::stack<int>>(true), ""); + static_assert(test_property<is_swappable, + std::stack<int>[1]>(true), ""); + static_assert(test_property<is_swappable, + std::stack<int>[1][2]>(true), ""); + static_assert(test_property<is_swappable, + std::stack<int>[1][2][3]>(true), ""); + static_assert(test_property<is_swappable, + std::stack<construct::Nontrivial>>(true), ""); + // Negative tests. + static_assert(test_property<is_swappable, void>(false), ""); + static_assert(test_property<is_swappable, const void>(false), ""); + static_assert(test_property<is_swappable, void()>(false), ""); + static_assert(test_property<is_swappable, void() const>(false), ""); + static_assert(test_property<is_swappable, void() volatile>(false), ""); + static_assert(test_property<is_swappable, + void() const volatile>(false), ""); + static_assert(test_property<is_swappable, const int>(false), ""); + static_assert(test_property<is_swappable, const bool>(false), ""); + static_assert(test_property<is_swappable, int[]>(false), ""); + static_assert(test_property<is_swappable, const int[]>(false), ""); + static_assert(test_property<is_swappable, int[][1]>(false), ""); + static_assert(test_property<is_swappable, const int[1]>(false), ""); + static_assert(test_property<is_swappable, const int[1][2]>(false), ""); + static_assert(test_property<is_swappable, const int[1][2][3]>(false), ""); + static_assert(test_property<is_swappable, construct::DelCopy>(false), ""); + static_assert(test_property<is_swappable, + construct::Abstract>(false), ""); + static_assert(test_property<is_swappable, + construct::NontrivialUnion>(false), ""); + static_assert(test_property<is_swappable, funny::F>(false), ""); + static_assert(test_property<is_swappable, funny::F[1]>(false), ""); + static_assert(test_property<is_swappable, funny::F[1][2]>(false), ""); + static_assert(test_property<is_swappable, funny::F[1][2][3]>(false), ""); + static_assert(test_property<is_swappable, funny::F[4]>(false), ""); + static_assert(test_property<is_swappable, construct::DelCopy>(false), ""); + static_assert(test_property<is_swappable, + DeletedCopyAssignClass>(false), ""); + static_assert(test_property<is_swappable, + DeletedMoveAssignClass>(false), ""); + static_assert(test_property<is_swappable, funny::F2>(false), ""); + static_assert(test_property<is_swappable, funny::F2[1]>(false), ""); + static_assert(test_property<is_swappable, funny::F2[1][2]>(false), ""); + static_assert(test_property<is_swappable, funny::F2[1][2][3]>(false), ""); + static_assert(test_property<is_swappable, funny::F2[4]>(false), ""); + static_assert(test_property<is_swappable, funny::F2[5]>(false), ""); +} diff --git a/libstdc++-v3/testsuite/20_util/is_swappable/value_ext.cc b/libstdc++-v3/testsuite/20_util/is_swappable/value_ext.cc new file mode 100644 index 00000000000..c7e3384d35e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_swappable/value_ext.cc @@ -0,0 +1,22 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#define test_std_is_swappable_ext +#include "./value.h" diff --git a/libstdc++-v3/testsuite/20_util/is_swappable_with/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_swappable_with/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..47fb3d56a1b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_swappable_with/requirements/explicit_instantiation.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> + +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_swappable_with missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_swappable_with has wrong value" +#endif + +namespace std +{ + typedef short test_type; + typedef double test_type_2; + template struct is_swappable_with<test_type, test_type>; + template struct is_swappable_with<test_type, test_type_2>; + template struct is_swappable_with<test_type_2, test_type_2>; +} diff --git a/libstdc++-v3/testsuite/20_util/is_swappable_with/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_swappable_with/requirements/typedefs.cc new file mode 100644 index 00000000000..f7935837775 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_swappable_with/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> + +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_swappable_with missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_swappable_with has wrong value" +#endif + +void test01() +{ + // Check for required typedefs + typedef std::is_swappable_with<int, int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_swappable_with/value.cc b/libstdc++-v3/testsuite/20_util/is_swappable_with/value.cc new file mode 100644 index 00000000000..be7d062b331 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_swappable_with/value.cc @@ -0,0 +1,113 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_tr1.h> + +#ifndef __cpp_lib_is_swappable +# error "Feature-test macro for is_swappable_with missing" +#elif __cpp_lib_is_swappable != 201603 +# error "Feature-test macro for is_swappable_with has wrong value" +#endif + +namespace funny { + struct T0 {}; + + void swap(T0, T0); + + struct T1 {}; + struct T2 {}; + + void swap(T1, T2); + void swap(T2, T1); + + struct BoolLike {}; + + void swap(BoolLike, bool&); + void swap(bool&, BoolLike); + + struct F0 {}; + + void swap(F0, F0) = delete; + + struct F1 {}; + + void swap(F0, F1) = delete; + void swap(F1, F0) = delete; + + struct F2 {}; + struct F3 {}; + + void swap(F2, F3); + void swap(F3, F2) = delete; + + struct F4 + { + friend void swap(F4, F4) = delete; + }; +} + +void test01() +{ + using std::is_swappable_with; + using namespace __gnu_test; + // Positive tests. + static_assert(test_property<is_swappable_with, int&, int&>(true), ""); + static_assert(test_property<is_swappable_with, funny::T0, + funny::T0>(true), ""); + static_assert(test_property<is_swappable_with, funny::T0, + const funny::T0>(true), ""); + static_assert(test_property<is_swappable_with, funny::T1, + funny::T2>(true), ""); + static_assert(test_property<is_swappable_with, funny::T2, + funny::T1>(true), ""); + static_assert(test_property<is_swappable_with, funny::BoolLike, + bool&>(true), ""); + static_assert(test_property<is_swappable_with, const funny::BoolLike, + bool&>(true), ""); + + // Negative tests. + static_assert(test_property<is_swappable_with, int, int>(false), ""); + static_assert(test_property<is_swappable_with, int&, unsigned&>(false), ""); + static_assert(test_property<is_swappable_with, const int&, + const int&>(false), ""); + static_assert(test_property<is_swappable_with, funny::F0, + funny::F0>(false), ""); + static_assert(test_property<is_swappable_with, funny::F0, + const funny::F0>(false), ""); + static_assert(test_property<is_swappable_with, funny::T0, + funny::T1>(false), ""); + static_assert(test_property<is_swappable_with, funny::F0, + funny::F1>(false), ""); + static_assert(test_property<is_swappable_with, funny::F0, + const funny::F1>(false), ""); + static_assert(test_property<is_swappable_with, const funny::F0, + funny::F1>(false), ""); + static_assert(test_property<is_swappable_with, funny::F2, + funny::F3>(false), ""); + static_assert(test_property<is_swappable_with, funny::F2, + const funny::F3>(false), ""); + static_assert(test_property<is_swappable_with, const funny::F2, + funny::F3>(false), ""); + static_assert(test_property<is_swappable_with, funny::F4, + funny::F4>(false), ""); + static_assert(test_property<is_swappable_with, funny::BoolLike, + funny::BoolLike>(false), ""); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc index 052b79fcf83..bc45780cb98 100644 --- a/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc @@ -162,8 +162,30 @@ void test01() } +void test02() +{ + bool test __attribute__((unused)) = true; + using std::allocator_arg; + using std::tuple; + using std::make_tuple; + + typedef tuple<> test_type; + + MyAlloc a; + + // default construction + test_type t1(allocator_arg, a); + // copy construction + test_type t2(allocator_arg, a, t1); + // move construction + test_type t3(allocator_arg, a, std::move(t1)); + // make_tuple + test_type empty = make_tuple(); +} + int main() { test01(); + test02(); return 0; } diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc index 3f5421b35e7..ad09d41ef5a 100644 --- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc @@ -28,6 +28,6 @@ int n1 = std::get<1>(a); int n2 = std::get<1>(std::move(a)); int n3 = std::get<1>(ca); -// { dg-error "static assertion failed" "" { target *-*-* } 283 } -// { dg-error "static assertion failed" "" { target *-*-* } 292 } -// { dg-error "static assertion failed" "" { target *-*-* } 300 } +// { dg-error "static assertion failed" "" { target *-*-* } 295 } +// { dg-error "static assertion failed" "" { target *-*-* } 304 } +// { dg-error "static assertion failed" "" { target *-*-* } 312 } diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc index 80a93e3b098..738bf17f735 100644 --- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc @@ -23,4 +23,4 @@ typedef std::tuple_element<1, std::array<int, 1>>::type type; -// { dg-error "static assertion failed" "" { target *-*-* } 331 } +// { dg-error "static assertion failed" "" { target *-*-* } 343 } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/71181.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/71181.cc new file mode 100644 index 00000000000..a8bbfc736d9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/71181.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++11" } + +#include <unordered_set> + +#include <testsuite_hooks.h> + +template<typename _USet> + void test(int threshold) + { + bool test __attribute__((unused)) = true; + _USet us; + auto nb_reserved = us.bucket_count(); + us.reserve(nb_reserved); + auto bkts = us.bucket_count(); + for (int i = 0; i != threshold; ++i) + { + if (i == nb_reserved) + { + nb_reserved = bkts; + us.reserve(nb_reserved); + bkts = us.bucket_count(); + } + + us.insert(i); + + VERIFY( us.bucket_count() == bkts ); + } + } + +template<typename _Value> + using unordered_set_power2_rehash = + std::_Hashtable<_Value, _Value, std::allocator<_Value>, + std::__detail::_Identity, + std::equal_to<_Value>, + std::hash<_Value>, + std::__detail::_Mask_range_hashing, + std::__detail::_Default_ranged_hash, + std::__detail::_Power2_rehash_policy, + std::__detail::_Hashtable_traits<false, true, true>>; + +int main() +{ + test<std::unordered_set<int>>(150); + test<unordered_set_power2_rehash<int>>(150); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/power2_rehash.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/power2_rehash.cc index 1d01d0a19f5..5805f7aafc6 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/power2_rehash.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/power2_rehash.cc @@ -17,6 +17,7 @@ // // { dg-options "-std=gnu++11" } +#include <limits> #include <unordered_set> #include <testsuite_hooks.h> @@ -35,8 +36,32 @@ void test01() == (std::size_t(1) << (sizeof(std::size_t) * 8 - 1)) ); } +void test02() +{ + bool test __attribute__((unused)) = true; + + std::__detail::_Power2_rehash_policy policy; + + for (std::size_t i = 1;;) + { + auto nxt = policy._M_next_bkt(i); + + if (nxt == i) + { + // Equals only when reaching max. + constexpr auto mx = std::numeric_limits<std::size_t>::max(); + VERIFY( nxt == policy._M_next_bkt(mx) ); + break; + } + + VERIFY( nxt > i ); + i = nxt; + } +} + int main() { test01(); + test02(); return 0; } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/prime_rehash.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/prime_rehash.cc new file mode 100644 index 00000000000..403382349fa --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/prime_rehash.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++11" } + +#include <limits> +#include <unordered_set> + +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::__detail::_Prime_rehash_policy policy; + + for (std::size_t i = 1;;) + { + auto nxt = policy._M_next_bkt(i); + + if (nxt == i) + { + // Equals only when reaching max. + constexpr auto mx = std::numeric_limits<std::size_t>::max() - 1; + VERIFY( nxt == policy._M_next_bkt(mx) ); + break; + } + + VERIFY( nxt > i ); + i = nxt; + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/rehash.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/rehash.cc index 2dac583598d..96581317446 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/rehash.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/rehash.cc @@ -22,40 +22,40 @@ #include <testsuite_hooks.h> template<typename _USet> -void test() -{ - bool test __attribute__((unused)) = true; - _USet us; - typedef typename _USet::size_type size_type; - bool rehashed = false; - for (int i = 0; i != 100000; ++i) + void test() { - size_type bkt_count = us.bucket_count(); - us.insert(i); - if (bkt_count != us.bucket_count()) + bool test __attribute__((unused)) = true; + _USet us; + typedef typename _USet::size_type size_type; + bool rehashed = false; + for (int i = 0; i != 100000; ++i) { - // Container has been rehashed, lets check that it won't be rehash again - // if we remove and restore the last 2 inserted elements: - rehashed = true; - bkt_count = us.bucket_count(); - VERIFY( us.erase(i) == 1 ); - VERIFY( bkt_count == us.bucket_count() ); - if (i > 0) + size_type bkt_count = us.bucket_count(); + us.insert(i); + if (bkt_count != us.bucket_count()) { - VERIFY( us.erase(i - 1) == 1 ); + // Container has been rehashed, lets check that it won't be rehash + // again if we remove and restore the last 2 inserted elements: + rehashed = true; + bkt_count = us.bucket_count(); + VERIFY( us.erase(i) == 1 ); VERIFY( bkt_count == us.bucket_count() ); + if (i > 0) + { + VERIFY( us.erase(i - 1) == 1 ); + VERIFY( bkt_count == us.bucket_count() ); - VERIFY( us.insert(i - 1).second ); + VERIFY( us.insert(i - 1).second ); + VERIFY( bkt_count == us.bucket_count() ); + } + VERIFY( us.insert(i).second ); VERIFY( bkt_count == us.bucket_count() ); } - VERIFY( us.insert(i).second ); - VERIFY( bkt_count == us.bucket_count() ); } - } - // At lest we check a rehash once: - VERIFY( rehashed ); -} + // At lest we check a rehash once: + VERIFY( rehashed ); + } template<typename _Value> using unordered_set_power2_rehash = diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc new file mode 100644 index 00000000000..39a3f031b46 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc @@ -0,0 +1,573 @@ +// { dg-options "-std=gnu++11" } + +// The class X and test code is by by Howard Hinnant and used under a +// Creative Commons Attribution 4.0 International License. +// http://creativecommons.org/licenses/by/4.0/ +// https://github.com/HowardHinnant/papers/blob/master/insert_vs_emplace.html +// +// The original code was reformatted and modified to use the VERIFY macro +// instead of writing to standard output. + +#include <testsuite_hooks.h> +#include <vector> +#include <iostream> + +class X +{ + int i_; + int* p_; + +public: + struct special + { + unsigned c; + unsigned dt; + unsigned cc; + unsigned ca; + unsigned mc; + unsigned ma; + }; + static special sp; + + X(int i, int* p) + : i_(i) + , p_(p) + { + // std::cout << "X(int i, int* p)\n"; + sp.c++; + } + + ~X() + { + // std::cout << "~X()\n"; + sp.dt++; + } + + X(const X& x) + : i_(x.i_) + , p_(x.p_) + { + // std::cout << "X(const X& x)\n"; + sp.cc++; + } + + X& operator=(const X& x) + { + + i_ = x.i_; + p_ = x.p_; + // std::cout << "X& operator=(const X& x)\n"; + sp.ca++; + return *this; + } + + X(X&& x) noexcept + : i_(x.i_) + , p_(x.p_) + { + // std::cout << "X(X&& x)\n"; + sp.mc++; + } + + X& operator=(X&& x) noexcept + { + + i_ = x.i_; + p_ = x.p_; + // std::cout << "X& operator=(X&& x)\n"; + sp.ma++; + return *this; + } + +}; + +std::ostream& +operator<<(std::ostream& os, X::special const& sp) +{ + os << sp.c << '\n'; + os << sp.dt << '\n'; + os << sp.cc << '\n'; + os << sp.ca << '\n'; + os << sp.mc << '\n'; + os << sp.ma << '\n'; + return os; +} + +X::special X::sp{}; + +bool +operator==(const X::special& lhs, const X::special& rhs) +{ + return lhs.c == rhs.c && lhs.dt == rhs.dt + && lhs.cc == rhs.cc && lhs.ca == rhs.ca + && lhs.mc == rhs.mc && lhs.ma == rhs.ma; +} + +// Verify that insert and emplace are equally efficient. +// Also verify exact number of operations (which are specific to this +// implementation) in order to catch any regressions. + +// insert vs emplace lvalue no reallocation +void +test01() +{ + const X::special expected{ 0, 1, 1, 0, 1, 3 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--insert lvalue no reallocation--\n"; + X::sp = {}; + v.insert(v.begin(), x); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--emplace lvalue no reallocation--\n"; + X::sp = {}; + v.emplace(v.begin(), x); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// insert vs emplace xvalue no reallocation +void +test02() +{ + const X::special expected{ 0, 0, 0, 0, 1, 3 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--insert xvalue no reallocation--\n"; + X::sp = {}; + v.insert(v.begin(), std::move(x)); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--emplace xvalue no reallocation--\n"; + X::sp = {}; + v.emplace(v.begin(), std::move(x)); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// insert vs emplace rvalue no reallocation +void +test03() +{ + const X::special expected{ 1, 1, 0, 0, 1, 3 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + // std::cout << "--insert rvalue no reallocation--\n"; + X::sp = {}; + v.insert(v.begin(), X{0,0}); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + // std::cout << "--emplace rvalue no reallocation--\n"; + X::sp = {}; + v.emplace(v.begin(), X{0,0}); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// insert vs emplace lvalue reallocation +void +test04() +{ + const X::special expected{ 0, 3, 1, 0, 3, 0 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--insert lvalue reallocation--\n"; + X::sp = {}; + v.insert(v.begin(), x); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--emplace lvalue reallocation--\n"; + X::sp = {}; + v.emplace(v.begin(), x); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// insert vs emplace xvalue reallocation +void +test05() +{ + const X::special expected{ 0, 3, 0, 0, 4, 0 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--insert xvalue reallocation--\n"; + X::sp = {}; + v.insert(v.begin(), std::move(x)); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--emplace xvalue reallocation--\n"; + X::sp = {}; + v.emplace(v.begin(), std::move(x)); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// insert vs emplace rvalue reallocation +void +test06() +{ + const X::special expected{ 1, 4, 0, 0, 4, 0 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + // std::cout << "--insert rvalue reallocation--\n"; + X::sp = {}; + v.insert(v.begin(), X{0,0}); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + // std::cout << "--emplace rvalue reallocation--\n"; + X::sp = {}; + v.emplace(v.begin(), X{0,0}); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// push_back vs emplace_back lvalue no reallocation +void +test07() +{ + const X::special expected{ 0, 0, 1, 0, 0, 0 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--push_back lvalue no reallocation--\n"; + X::sp = {}; + v.push_back(x); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--emplace_back lvalue no reallocation--\n"; + X::sp = {}; + v.emplace_back(x); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// push_back vs emplace_back xvalue no reallocation +void +test08() +{ + const X::special expected{ 0, 0, 0, 0, 1, 0 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--push_back xvalue no reallocation--\n"; + X::sp = {}; + v.push_back(std::move(x)); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--emplace_back xvalue no reallocation--\n"; + X::sp = {}; + v.emplace_back(std::move(x)); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// push_back vs emplace_back rvalue no reallocation +void +test09() +{ + const X::special expected{ 1, 1, 0, 0, 1, 0 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + // std::cout << "--push_back rvalue no reallocation--\n"; + X::sp = {}; + v.push_back(X{0,0}); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(4); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + // std::cout << "--emplace_back rvalue no reallocation--\n"; + X::sp = {}; + v.emplace_back(X{0,0}); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// push_back vs emplace_back lvalue reallocation +void +test10() +{ + const X::special expected{ 0, 3, 1, 0, 3, 0 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--push_back lvalue reallocation--\n"; + X::sp = {}; + v.push_back(x); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--emplace_back lvalue reallocation--\n"; + X::sp = {}; + v.emplace_back(x); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// push_back vs emplace_back xvalue reallocation +void +test11() +{ + const X::special expected{ 0, 3, 0, 0, 4, 0 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--push_back xvalue reallocation--\n"; + X::sp = {}; + v.push_back(std::move(x)); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + X x{0,0}; + // std::cout << "--emplace_back xvalue reallocation--\n"; + X::sp = {}; + v.emplace_back(std::move(x)); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +// push_back vs emplace_back rvalue reallocation +void +test12() +{ + const X::special expected{ 1, 4, 0, 0, 4, 0 }; + X::special ins, emp; + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + // std::cout << "--push_back rvalue reallocation--\n"; + X::sp = {}; + v.push_back(X{0,0}); + // std::cout << X::sp; + // std::cout << "----\n"; + ins = X::sp; + } + { + std::vector<X> v; + v.reserve(3); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + v.push_back(X(0,0)); + // std::cout << "--emplace_back rvalue reallocation--\n"; + X::sp = {}; + v.emplace_back(X{0,0}); + // std::cout << X::sp; + // std::cout << "----\n"; + emp = X::sp; + } + VERIFY( ins == emp ); + VERIFY( ins == expected ); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + test06(); + test07(); + test08(); + test09(); + test10(); + test11(); + test12(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/partitioned.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/partitioned.cc new file mode 100644 index 00000000000..63a6cada97e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/partitioned.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } + +#include <algorithm> +#include <functional> +#include <testsuite_iterators.h> +#include <testsuite_hooks.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +struct X +{ + int val; + + bool odd() const { return val % 2; } + + // Partitioned so that all odd values come before even values: + bool operator<(const X& x) const { return this->odd() && !x.odd(); } +}; + +void +test01() +{ + bool test __attribute((unused)) = true; + + // Test with range that is partitioned, but not sorted. + X seq[] = { 1, 3, 5, 7, 1, 6, 4 }; + test_container<X, forward_iterator_wrapper> c(seq); + + auto b1 = std::binary_search(c.begin(), c.end(), X{2}); + VERIFY( b1 ); + auto b2 = std::binary_search(c.begin(), c.end(), X{2}, std::less<X>{}); + VERIFY( b2 ); + + auto b3 = std::binary_search(c.begin(), c.end(), X{9}); + VERIFY( b3 ); + auto b4 = std::binary_search(c.begin(), c.end(), X{9}, std::less<X>{}); + VERIFY( b4 ); + + auto b5 = std::binary_search(seq, seq+5, X{2}); + VERIFY( !b5 ); + auto b6 = std::binary_search(seq, seq+5, X{2}, std::less<X>{}); + VERIFY( !b6 ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/partitioned.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/partitioned.cc new file mode 100644 index 00000000000..d3a43d06a58 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/partitioned.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } + +#include <algorithm> +#include <functional> +#include <testsuite_iterators.h> +#include <testsuite_hooks.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +struct X +{ + int val; + + bool odd() const { return val % 2; } + + // Partitioned so that all odd values come before even values: + bool operator<(const X& x) const { return this->odd() && !x.odd(); } +}; + +void +test01() +{ + bool test __attribute((unused)) = true; + + // Test with range that is partitioned, but not sorted. + X seq[] = { 1, 3, 5, 7, 1, 6, 4, 2 }; + test_container<X, forward_iterator_wrapper> c(seq); + + auto part1 = std::equal_range(c.begin(), c.end(), X{2}); + VERIFY( part1.first != c.end() && part1.second == c.end() ); + VERIFY( part1.first->val == 6 ); + auto part2 = std::equal_range(c.begin(), c.end(), X{2}, std::less<X>{}); + VERIFY( part2.first != c.end() && part1.second == c.end() ); + VERIFY( part2.first->val == 6 ); + + auto part3 = std::equal_range(c.begin(), c.end(), X{9}); + VERIFY( part3.first == c.begin() && part3.second != c.end() ); + VERIFY( part3.second->val == 6 ); + auto part4 = std::equal_range(c.begin(), c.end(), X{9}, std::less<X>{}); + VERIFY( part4.first == c.begin() && part4.second != c.end() ); + VERIFY( part4.second->val == 6 ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/71545.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/71545.cc new file mode 100644 index 00000000000..6c9cd12cfef --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/71545.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } +// { dg-do link } + +#include <algorithm> + +struct X { }; + +bool operator<(X, int) { return true; } +bool operator<(int, X) { return false; } + +bool operator<(X, X); // undefined (PR libstdc++/71545) + +int main() +{ + X x[1]; + int i[1]; + std::lexicographical_compare(x, x+1, i, i+1); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/partitioned.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/partitioned.cc new file mode 100644 index 00000000000..bba0b66ea80 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/partitioned.cc @@ -0,0 +1,100 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } + +#include <algorithm> +#include <functional> +#include <testsuite_iterators.h> +#include <testsuite_hooks.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +struct X +{ + int val; + + bool odd() const { return val % 2; } + + // Partitioned so that all odd values come before even values: + bool operator<(const X& x) const { return this->odd() && !x.odd(); } +}; + +void +test01() +{ + bool test __attribute((unused)) = true; + + // Test with range that is partitioned, but not sorted. + X seq[] = { 1, 3, 5, 7, 1, 6, 4, 2 }; + test_container<X, forward_iterator_wrapper> c(seq); + + auto part1 = std::lower_bound(c.begin(), c.end(), X{2}); + VERIFY( part1 != c.end() ); + VERIFY( part1->val == 6 ); + auto part2 = std::lower_bound(c.begin(), c.end(), X{2}, std::less<X>{}); + VERIFY( part2 != c.end() ); + VERIFY( part2->val == 6 ); + + auto part3 = std::lower_bound(c.begin(), c.end(), X{9}); + VERIFY( part3 != c.end() ); + VERIFY( part3->val == 1 ); + auto part4 = std::lower_bound(c.begin(), c.end(), X{9}, std::less<X>{}); + VERIFY( part4 != c.end() ); + VERIFY( part4->val == 1 ); +} + +struct Y +{ + double val; + + // Not irreflexive, so not a strict weak order. + bool operator<(const Y& y) const { return val < int(y.val); } +}; + +void +test02() +{ + bool test __attribute((unused)) = true; + + // Test that Debug Mode checks don't fire (libstdc++/71545) + + Y seq[] = { -0.1, 1.2, 5.0, 5.2, 5.1, 5.9, 5.5, 6.0 }; + test_container<Y, forward_iterator_wrapper> c(seq); + + auto part1 = std::lower_bound(c.begin(), c.end(), Y{5.5}); + VERIFY( part1 != c.end() ); + VERIFY( part1->val == 5.0 ); + auto part2 = std::lower_bound(c.begin(), c.end(), Y{5.5}, std::less<Y>{}); + VERIFY( part2 != c.end() ); + VERIFY( part2->val == 5.0 ); + + auto part3 = std::lower_bound(c.begin(), c.end(), Y{1.0}); + VERIFY( part3 != c.end() ); + VERIFY( part3->val == 1.2 ); + auto part4 = std::lower_bound(c.begin(), c.end(), Y{1.0}, std::less<Y>{}); + VERIFY( part4 != c.end() ); + VERIFY( part4->val == 1.2 ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/partitioned.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/partitioned.cc new file mode 100644 index 00000000000..96cfb2e2ded --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/partitioned.cc @@ -0,0 +1,98 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } + +#include <algorithm> +#include <functional> +#include <testsuite_iterators.h> +#include <testsuite_hooks.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +struct X +{ + int val; + + bool odd() const { return val % 2; } + + // Partitioned so that all odd values come before even values: + bool operator<(const X& x) const { return this->odd() && !x.odd(); } +}; + +void +test01() +{ + bool test __attribute((unused)) = true; + + // Test with range that is partitioned, but not sorted. + X seq[] = { 1, 3, 5, 7, 1, 6, 4, 2 }; + test_container<X, forward_iterator_wrapper> c(seq); + + auto part1 = std::upper_bound(c.begin(), c.end(), X{2}); + VERIFY( part1 == c.end() ); + auto part2 = std::upper_bound(c.begin(), c.end(), X{2}, std::less<X>{}); + VERIFY( part2 == c.end() ); + + auto part3 = std::upper_bound(c.begin(), c.end(), X{9}); + VERIFY( part3 != c.end() ); + VERIFY( part3->val == 6 ); + auto part4 = std::upper_bound(c.begin(), c.end(), X{9}, std::less<X>{}); + VERIFY( part3 != c.end() ); + VERIFY( part4->val == 6 ); +} + +struct Y +{ + double val; + + // Not irreflexive, so not a strict weak order. + bool operator<(const Y& y) const { return val < (int)y.val; } +}; + +void +test02() +{ + bool test __attribute((unused)) = true; + + // Test that Debug Mode checks don't fire (libstdc++/71545) + + Y seq[] = { -0.1, 1.2, 5.0, 5.2, 5.1, 5.9, 5.5, 6.0 }; + test_container<Y, forward_iterator_wrapper> c(seq); + + auto part1 = std::upper_bound(c.begin(), c.end(), Y{5.5}); + VERIFY( part1 != c.end() ); + VERIFY( part1->val == 6.0 ); + auto part2 = std::upper_bound(c.begin(), c.end(), Y{5.5}, std::less<Y>{}); + VERIFY( part2 != c.end() ); + VERIFY( part2->val == 6.0 ); + + auto part3 = std::upper_bound(c.begin(), c.end(), Y{1.0}); + VERIFY( part3 != c.end() ); + VERIFY( part3->val == 5.0 ); + auto part4 = std::upper_bound(c.begin(), c.end(), Y{1.0}, std::less<Y>{}); + VERIFY( part4 != c.end() ); + VERIFY( part4->val == 5.0 ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc new file mode 100644 index 00000000000..e4148609c2b --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// 15.26 Permissions [fs.op.permissions] + +#include <experimental/filesystem> +#include <fstream> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using perms = std::experimental::filesystem::perms; + + auto p = __gnu_test::nonexistent_path(); + std::ofstream{p.native()}; + VERIFY( exists(p) ); + permissions(p, perms::owner_all); + VERIFY( status(p).permissions() == perms::owner_all ); + permissions(p, perms::group_read | perms::add_perms); + VERIFY( status(p).permissions() == (perms::owner_all | perms::group_read) ); + permissions(p, perms::group_read | perms::remove_perms); + VERIFY( status(p).permissions() == perms::owner_all ); + + remove(p); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index a1c71a23cdd..53c9b3d4f64 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -542,6 +542,13 @@ namespace __gnu_test test_container(T* _first, T* _last):bounds(_first, _last) { } +#if __cplusplus >= 201103L + template<std::size_t N> + explicit + test_container(T (&arr)[N]) : test_container(arr, arr+N) + { } +#endif + ItType<T> it(int pos) { |