diff options
Diffstat (limited to 'libstdc++-v3/include')
21 files changed, 323 insertions, 311 deletions
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 948a5c1f1c5..44b87ec0480 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -205,6 +205,7 @@ VTV_CXXLINKFLAGS = @VTV_CXXLINKFLAGS@ VTV_PCH_CXXFLAGS = @VTV_PCH_CXXFLAGS@ WARN_FLAGS = @WARN_FLAGS@ WERROR = @WERROR@ +XMLCATALOG = @XMLCATALOG@ XMLLINT = @XMLLINT@ XSLTPROC = @XSLTPROC@ XSL_STYLE_DIR = @XSL_STYLE_DIR@ diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index d9e18bfc30a..7ae68f623d1 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 template<typename _Tp1, typename _Tp2 = void> using _Path = typename std::enable_if<__and_<__not_<is_same<remove_cv_t<_Tp1>, path>>, - __not_<is_void<_Tp1>>, + __not_<is_void<remove_pointer_t<_Tp1>>>, __constructible_from<_Tp1, _Tp2>>::value, path>::type; @@ -168,7 +168,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 path(path&& __p) noexcept : _M_pathname(std::move(__p._M_pathname)), _M_type(__p._M_type) { - _M_split_cmpts(); + if (_M_type == _Type::_Multi) + _M_split_cmpts(); __p.clear(); } @@ -478,7 +479,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 static basic_string<_CharT, _Traits, _Allocator> _S_str_convert(const string_type&, const _Allocator& __a); - bool _S_is_dir_sep(value_type __ch) + static bool _S_is_dir_sep(value_type __ch) { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS return __ch == L'/' || __ch == preferred_separator; diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 475cda6cac5..0d19f1cf155 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -1368,12 +1368,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { clear(); _M_deallocate_buckets(); - - static_assert(__is_invocable<const _H1&, const _Key&>{}, - "hash function must be invocable with an argument of key type"); - static_assert(__is_invocable<const _Equal&, const _Key&, const _Key&>{}, - "key equality predicate must be invocable with two arguments of " - "key type"); } template<typename _Key, typename _Value, diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 3ff6b14a90f..aa192a9656d 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1296,7 +1296,11 @@ namespace __detail __hash_code _M_hash_code(const _Key& __k) const - { return _M_h1()(__k); } + { + static_assert(__is_invocable<const _H1&, const _Key&>{}, + "hash function must be invocable with an argument of key type"); + return _M_h1()(__k); + } std::size_t _M_bucket_index(const _Key&, __hash_code __c, std::size_t __n) const @@ -1384,7 +1388,11 @@ namespace __detail __hash_code _M_hash_code(const _Key& __k) const - { return _M_h1()(__k); } + { + static_assert(__is_invocable<const _H1&, const _Key&>{}, + "hash function must be invocable with an argument of key type"); + return _M_h1()(__k); + } std::size_t _M_bucket_index(const _Key&, __hash_code __c, @@ -1830,6 +1838,9 @@ namespace __detail bool _M_equals(const _Key& __k, __hash_code __c, __node_type* __n) const { + static_assert(__is_invocable<const _Equal&, const _Key&, const _Key&>{}, + "key equality predicate must be invocable with two arguments of " + "key type"); return _EqualHelper::_S_equals(_M_eq(), this->_M_extract(), __k, __c, __n); } diff --git a/libstdc++-v3/include/bits/memoryfwd.h b/libstdc++-v3/include/bits/memoryfwd.h index 9ecadba3055..4a77e10d597 100644 --- a/libstdc++-v3/include/bits/memoryfwd.h +++ b/libstdc++-v3/include/bits/memoryfwd.h @@ -66,9 +66,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> class allocator<void>; +#if __cplusplus >= 201103L /// Declare uses_allocator so it can be specialized in \<queue\> etc. template<typename, typename> struct uses_allocator; +#endif /// @} group memory diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index f812bbf18b1..c776dc62d21 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -5982,9 +5982,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t size() const noexcept { return _M_v.size(); } - template<typename OutputIterator> + template<typename _OutputIterator> void - param(OutputIterator __dest) const + param(_OutputIterator __dest) const { std::copy(_M_v.begin(), _M_v.end(), __dest); } // no copy functions diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 1fcd7dba34d..a8ea52cd65b 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -998,27 +998,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Precondition: __n > 0. inline _GLIBCXX_CONSTEXPR int __lg(int __n) - { return sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } + { return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } inline _GLIBCXX_CONSTEXPR unsigned __lg(unsigned __n) - { return sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } + { return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } inline _GLIBCXX_CONSTEXPR long __lg(long __n) - { return sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } + { return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } inline _GLIBCXX_CONSTEXPR unsigned long __lg(unsigned long __n) - { return sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } + { return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } inline _GLIBCXX_CONSTEXPR long long __lg(long long __n) - { return sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } + { return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } inline _GLIBCXX_CONSTEXPR unsigned long long __lg(unsigned long long __n) - { return sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } + { return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } _GLIBCXX_BEGIN_NAMESPACE_ALGO diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index fd96a63593a..3d4c090886b 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -762,7 +762,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static const _Key& _S_key(_Const_Link_type __x) - { return _KeyOfValue()(_S_value(__x)); } + { +#if __cplusplus >= 201103L + // If we're asking for the key we're presumably using the comparison + // object, and so this is a good place to sanity check it. + static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{}, + "comparison object must be invocable " + "with two arguments of key type"); +# if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2542. Missing const requirements for associative containers + if constexpr (__is_invocable<_Compare&, const _Key&, const _Key&>{}) + static_assert( + is_invocable_v<const _Compare&, const _Key&, const _Key&>, + "comparison object must be invocable as const"); +# endif // C++17 +#endif // C++11 + + return _KeyOfValue()(*__x->_M_valptr()); + } static _Link_type _S_left(_Base_ptr __x) _GLIBCXX_NOEXCEPT @@ -786,7 +804,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static const _Key& _S_key(_Const_Base_ptr __x) - { return _KeyOfValue()(_S_value(__x)); } + { return _S_key(static_cast<_Const_Link_type>(__x)); } static _Base_ptr _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT @@ -951,21 +969,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif ~_Rb_tree() _GLIBCXX_NOEXCEPT - { - _M_erase(_M_begin()); - -#if __cplusplus >= 201103L - static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{}, - "comparison object must be invocable " - "with two arguments of key type"); -# if __cplusplus >= 201703L - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 2542. Missing const requirements for associative containers - static_assert(is_invocable_v<const _Compare&, const _Key&, const _Key&>, - "comparison object must be invocable as const"); -# endif // C++17 -#endif // C++11 - } + { _M_erase(_M_begin()); } _Rb_tree& operator=(const _Rb_tree& __x); diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h index c740503052b..bb460f28e78 100644 --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -826,7 +826,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif -#if __cplusplus > 201402L +#if __cplusplus >= 201703L +# define __cpp_lib_raw_memory_algorithms 201606L + template <typename _ForwardIterator> inline void uninitialized_default_construct(_ForwardIterator __first, @@ -877,7 +879,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __count, __result); return {__res.first.base(), __res.second}; } -#endif +#endif // C++17 _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 129d45cd34b..298b38fe9cd 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -1600,11 +1600,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); } value_type& - _M_val() { return *reinterpret_cast<_Tp*>(&__buf); } + _M_val() { return *_M_ptr(); } private: - pointer - _M_ptr() { return pointer_traits<pointer>::pointer_to(_M_val()); } + _Tp* + _M_ptr() { return reinterpret_cast<_Tp*>(&__buf); } vector* _M_this; typename aligned_storage<sizeof(_Tp), alignof(_Tp)>::type __buf; diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index 8225e3a8290..90adf536cef 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -174,14 +174,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // unique_ptr template<typename _Up, typename _Ep> using __safe_conversion_up = __and_< - is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>, - __not_<is_array<_Up>>, - __or_<__and_<is_reference<deleter_type>, - is_same<deleter_type, _Ep>>, - __and_<__not_<is_reference<deleter_type>>, - is_convertible<_Ep, deleter_type>> - > - >; + is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>, + __not_<is_array<_Up>> + >; // Constructors. @@ -425,16 +420,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // helper template for detecting a safe conversion from another // unique_ptr template<typename _Up, typename _Ep, - typename _Up_up = unique_ptr<_Up, _Ep>, - typename _Up_element_type = typename _Up_up::element_type> + typename _UPtr = unique_ptr<_Up, _Ep>, + typename _UP_pointer = typename _UPtr::pointer, + typename _UP_element_type = typename _UPtr::element_type> using __safe_conversion_up = __and_< is_array<_Up>, is_same<pointer, element_type*>, - is_same<typename _Up_up::pointer, _Up_element_type*>, - is_convertible<_Up_element_type(*)[], element_type(*)[]>, - __or_<__and_<is_reference<deleter_type>, is_same<deleter_type, _Ep>>, - __and_<__not_<is_reference<deleter_type>>, - is_convertible<_Ep, deleter_type>>> + is_same<_UP_pointer, _UP_element_type*>, + is_convertible<_UP_element_type(*)[], element_type(*)[]> >; // helper template for detecting a safe conversion from a raw pointer @@ -519,8 +512,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename = _DeleterConstraint<_Up>> constexpr unique_ptr(nullptr_t) noexcept : _M_t() { } - template<typename _Up, typename _Ep, - typename = _Require<__safe_conversion_up<_Up, _Ep>>> + template<typename _Up, typename _Ep, typename = _Require< + __safe_conversion_up<_Up, _Ep>, + typename conditional<is_reference<_Dp>::value, + is_same<_Ep, _Dp>, + is_convertible<_Ep, _Dp>>::type>> unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) { } diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any index 641c2cb9c31..fe5c822dd50 100644 --- a/libstdc++-v3/include/experimental/any +++ b/libstdc++-v3/include/experimental/any @@ -300,7 +300,8 @@ inline namespace fundamentals_v1 _Storage _M_storage; template<typename _Tp> - friend void* __any_caster(const any* __any); + friend enable_if_t<is_object<_Tp>::value, void*> + __any_caster(const any* __any); // Manage in-place contained object. template<typename _Tp> @@ -410,19 +411,45 @@ inline namespace fundamentals_v1 } // @} + /// @cond undocumented template<typename _Tp> - void* __any_caster(const any* __any) + enable_if_t<is_object<_Tp>::value, void*> + __any_caster(const any* __any) { - struct _None { }; - using _Up = decay_t<_Tp>; - using _Vp = conditional_t<is_copy_constructible<_Up>::value, _Up, _None>; - if (__any->_M_manager != &any::_Manager<_Vp>::_S_manage) - return nullptr; - any::_Arg __arg; - __any->_M_manager(any::_Op_access, __any, &__arg); - return __arg._M_obj; + // any_cast<T> returns non-null if __any->type() == typeid(T) and + // typeid(T) ignores cv-qualifiers so remove them: + using _Up = remove_cv_t<_Tp>; + // The contained value has a decayed type, so if decay_t<U> is not U, + // then it's not possible to have a contained value of type U. + using __does_not_decay = is_same<decay_t<_Up>, _Up>; + // Only copy constructible types can be used for contained values. + using __is_copyable = is_copy_constructible<_Up>; + // If the type _Tp could never be stored in an any we don't want to + // instantiate _Manager<_Tp>, so use _Manager<any::_Op> instead, which + // is explicitly specialized and has a no-op _S_manage function. + using _Vp = conditional_t<__and_<__does_not_decay, __is_copyable>::value, + _Up, any::_Op>; + // First try comparing function addresses, which works without RTTI + if (__any->_M_manager == &any::_Manager<_Vp>::_S_manage +#if __cpp_rtti + || __any->type() == typeid(_Tp) +#endif + ) + { + any::_Arg __arg; + __any->_M_manager(any::_Op_access, __any, &__arg); + return __arg._M_obj; + } + return nullptr; } + // This overload exists so that std::any_cast<void(*)()>(a) is well-formed. + template<typename _Tp> + enable_if_t<!is_object<_Tp>::value, _Tp*> + __any_caster(const any*) noexcept + { return nullptr; } + /// @endcond + /** * @brief Access the contained object. * @@ -517,6 +544,14 @@ inline namespace fundamentals_v1 } } + // Dummy specialization used by __any_caster. + template<> + struct any::_Manager_internal<any::_Op> + { + static void + _S_manage(_Op, const any*, _Arg*) { } + }; + // @} group any } // namespace fundamentals_v1 } // namespace experimental diff --git a/libstdc++-v3/include/experimental/bits/fs_path.h b/libstdc++-v3/include/experimental/bits/fs_path.h index 088d62f8f43..705f76331b5 100644 --- a/libstdc++-v3/include/experimental/bits/fs_path.h +++ b/libstdc++-v3/include/experimental/bits/fs_path.h @@ -120,11 +120,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 : decltype(__is_path_src(std::declval<_Source>(), 0)) { }; - template<typename _Tp1, typename _Tp2 = void> + template<typename _Tp1, typename _Tp2 = void, + typename _Tp1_nocv = typename remove_cv<_Tp1>::type, + typename _Tp1_noptr = typename remove_pointer<_Tp1>::type> using _Path = typename - std::enable_if<__and_<__not_<is_same<typename remove_cv<_Tp1>::type, - path>>, - __not_<is_void<_Tp1>>, + std::enable_if<__and_<__not_<is_same<_Tp1_nocv, path>>, + __not_<is_void<_Tp1_noptr>>, __constructible_from<_Tp1, _Tp2>>::value, path>::type; @@ -185,7 +186,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 path(path&& __p) noexcept : _M_pathname(std::move(__p._M_pathname)), _M_type(__p._M_type) { - _M_split_cmpts(); + if (_M_type == _Type::_Multi) + _M_split_cmpts(); __p.clear(); } @@ -459,7 +461,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return _S_convert_loc(__tmp.data(), __tmp.data()+__tmp.size(), __loc); } - bool _S_is_dir_sep(value_type __ch) + static bool _S_is_dir_sep(value_type __ch) { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS return __ch == L'/' || __ch == preferred_separator; diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits index eb5c3c5a7ee..26a7c8d1383 100644 --- a/libstdc++-v3/include/experimental/type_traits +++ b/libstdc++-v3/include/experimental/type_traits @@ -251,12 +251,12 @@ template<typename _Default, template<typename...> class _Op, typename... _Args> template<typename _Default, template<typename...> class _Op, typename... _Args> using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; -template<typename Expected, template<typename...> class _Op, typename... _Args> - using is_detected_exact = is_same<Expected, detected_t<_Op, _Args...>>; +template<typename _Expected, template<typename...> class _Op, typename... _Args> + using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>; -template<typename Expected, template<typename...> class _Op, typename... _Args> +template<typename _Expected, template<typename...> class _Op, typename... _Args> constexpr bool is_detected_exact_v - = is_detected_exact<Expected, _Op, _Args...>::value; + = is_detected_exact<_Expected, _Op, _Args...>::value; template<typename _To, template<typename...> class _Op, typename... _Args> using is_detected_convertible diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index a37eb38d665..0aa9281be83 100644 --- a/libstdc++-v3/include/std/any +++ b/libstdc++-v3/include/std/any @@ -66,7 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif } -#define __cpp_lib_any 201603 +#define __cpp_lib_any 201606L /** * @brief A type-safe container of any type. @@ -503,20 +503,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } // @} + /// @cond undocumented template<typename _Tp> void* __any_caster(const any* __any) { - if constexpr (is_copy_constructible_v<decay_t<_Tp>>) + // any_cast<T> returns non-null if __any->type() == typeid(T) and + // typeid(T) ignores cv-qualifiers so remove them: + using _Up = remove_cv_t<_Tp>; + // The contained value has a decayed type, so if decay_t<U> is not U, + // then it's not possible to have a contained value of type U: + if constexpr (!is_same_v<decay_t<_Up>, _Up>) + return nullptr; + // Only copy constructible types can be used for contained values: + else if constexpr (!is_copy_constructible_v<_Up>) + return nullptr; + // First try comparing function addresses, which works without RTTI + else if (__any->_M_manager == &any::_Manager<_Up>::_S_manage +#if __cpp_rtti + || __any->type() == typeid(_Tp) +#endif + ) { - if (__any->_M_manager == &any::_Manager<decay_t<_Tp>>::_S_manage) - { - any::_Arg __arg; - __any->_M_manager(any::_Op_access, __any, &__arg); - return __arg._M_obj; - } + any::_Arg __arg; + __any->_M_manager(any::_Op_access, __any, &__arg); + return __arg._M_obj; } return nullptr; } + /// @endcond /** * @brief Access the contained object. @@ -532,16 +546,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _ValueType> inline const _ValueType* any_cast(const any* __any) noexcept { - if (__any) - return static_cast<_ValueType*>(__any_caster<_ValueType>(__any)); + if constexpr (is_object_v<_ValueType>) + if (__any) + return static_cast<_ValueType*>(__any_caster<_ValueType>(__any)); return nullptr; } template<typename _ValueType> inline _ValueType* any_cast(any* __any) noexcept { - if (__any) - return static_cast<_ValueType*>(__any_caster<_ValueType>(__any)); + if constexpr (is_object_v<_ValueType>) + if (__any) + return static_cast<_ValueType*>(__any_caster<_ValueType>(__any)); return nullptr; } // @} diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 9f5d24e0220..20153fb24c5 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -51,7 +51,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ -#define __cpp_lib_optional 201603 +#define __cpp_lib_optional 201606L template<typename _Tp> class optional; diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream index 448a9288188..2099294fd92 100644 --- a/libstdc++-v3/include/std/ostream +++ b/libstdc++-v3/include/std/ostream @@ -444,6 +444,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit sentry(basic_ostream<_CharT, _Traits>& __os); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" /** * @brief Possibly flushes the stream. * @@ -461,6 +463,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_os.setstate(ios_base::badbit); } } +#pragma GCC diagnostic pop /** * @brief Quick status checking. diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 220f4991546..e0394179963 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -867,58 +867,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __is_nt_destructible_safe<_Tp>::type { }; - struct __do_is_default_constructible_impl - { - template<typename _Tp, typename = decltype(_Tp())> - static true_type __test(int); - - template<typename> - static false_type __test(...); - }; - - template<typename _Tp> - struct __is_default_constructible_impl - : public __do_is_default_constructible_impl - { - typedef decltype(__test<_Tp>(0)) type; - }; - - template<typename _Tp> - struct __is_default_constructible_atom - : public __and_<__not_<is_void<_Tp>>, - __is_default_constructible_impl<_Tp>> - { }; - - template<typename _Tp, bool = is_array<_Tp>::value> - 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 - // functional casts of the form T(). Complete arrays can be default- - // 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> - : public __and_<__is_array_known_bounds<_Tp>, - __is_default_constructible_atom<typename - remove_all_extents<_Tp>::type>> - { }; - - template<typename _Tp> - struct __is_default_constructible_safe<_Tp, false> - : public __is_default_constructible_atom<_Tp>::type + /// is_constructible + template<typename _Tp, typename... _Args> + struct is_constructible + : public __bool_constant<__is_constructible(_Tp, _Args...)> { }; /// is_default_constructible template<typename _Tp> struct is_default_constructible - : public __is_default_constructible_safe<_Tp>::type - { }; - - /// is_constructible - template<typename _Tp, typename... _Args> - struct is_constructible - : public __bool_constant<__is_constructible(_Tp, _Args...)> + : public is_constructible<_Tp>::type { }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index ee39c4fc001..3b0099877ab 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -68,7 +68,7 @@ namespace __variant } // namespace __variant } // namespace __detail -#define __cpp_lib_variant 201603 +#define __cpp_lib_variant 201606L template<typename... _Types> class tuple; template<typename... _Types> class variant; @@ -809,9 +809,8 @@ namespace __variant { using _Alternative = variant_alternative_t<__index, _Next>; __element = __gen_vtable_impl< - remove_reference_t< - decltype(__element)>, tuple<_Variants...>, - std::index_sequence<__indices..., __index>>::_S_apply(); + remove_reference_t<decltype(__element)>, tuple<_Variants...>, + std::index_sequence<__indices..., __index>>::_S_apply(); } }; @@ -824,11 +823,11 @@ namespace __variant using _Array_type = _Multi_array<_Result_type (*)(_Visitor&&, _Variants...)>; - decltype(auto) - static constexpr __visit_invoke(_Visitor&& __visitor, _Variants... __vars) + static constexpr decltype(auto) + __visit_invoke(_Visitor&& __visitor, _Variants... __vars) { return std::__invoke(std::forward<_Visitor>(__visitor), - std::get<__indices>(std::forward<_Variants>(__vars))...); + __variant::__get<__indices>(std::forward<_Variants>(__vars))...); } static constexpr auto @@ -869,8 +868,8 @@ namespace __variant } // namespace __detail template<typename _Tp, typename... _Types> - inline constexpr bool holds_alternative(const variant<_Types...>& __v) - noexcept + constexpr bool + holds_alternative(const variant<_Types...>& __v) noexcept { static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, "T should occur for exactly once in alternatives"); @@ -878,7 +877,7 @@ namespace __variant } template<typename _Tp, typename... _Types> - constexpr inline _Tp& get(variant<_Types...>& __v) + constexpr _Tp& get(variant<_Types...>& __v) { static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, "T should occur for exactly once in alternatives"); @@ -887,7 +886,7 @@ namespace __variant } template<typename _Tp, typename... _Types> - constexpr inline _Tp&& get(variant<_Types...>&& __v) + constexpr _Tp&& get(variant<_Types...>&& __v) { static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, "T should occur for exactly once in alternatives"); @@ -897,7 +896,7 @@ namespace __variant } template<typename _Tp, typename... _Types> - constexpr inline const _Tp& get(const variant<_Types...>& __v) + constexpr const _Tp& get(const variant<_Types...>& __v) { static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, "T should occur for exactly once in alternatives"); @@ -906,7 +905,7 @@ namespace __variant } template<typename _Tp, typename... _Types> - constexpr inline const _Tp&& get(const variant<_Types...>&& __v) + constexpr const _Tp&& get(const variant<_Types...>&& __v) { static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, "T should occur for exactly once in alternatives"); @@ -916,8 +915,7 @@ namespace __variant } template<size_t _Np, typename... _Types> - constexpr inline - add_pointer_t<variant_alternative_t<_Np, variant<_Types...>>> + constexpr add_pointer_t<variant_alternative_t<_Np, variant<_Types...>>> get_if(variant<_Types...>* __ptr) noexcept { using _Alternative_type = variant_alternative_t<_Np, variant<_Types...>>; @@ -930,7 +928,7 @@ namespace __variant } template<size_t _Np, typename... _Types> - constexpr inline + constexpr add_pointer_t<const variant_alternative_t<_Np, variant<_Types...>>> get_if(const variant<_Types...>* __ptr) noexcept { @@ -944,7 +942,7 @@ namespace __variant } template<typename _Tp, typename... _Types> - constexpr inline add_pointer_t<_Tp> + constexpr add_pointer_t<_Tp> get_if(variant<_Types...>* __ptr) noexcept { static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, @@ -955,7 +953,7 @@ namespace __variant } template<typename _Tp, typename... _Types> - constexpr inline add_pointer_t<const _Tp> + constexpr add_pointer_t<const _Tp> get_if(const variant<_Types...>* __ptr) noexcept { @@ -1287,7 +1285,7 @@ namespace __variant { &__detail::__variant::__erased_##__NAME< \ const variant&, __indices>... }; \ template<size_t... __indices> \ - constexpr inline bool \ + constexpr bool \ _M_##__NAME(const variant& __rhs, \ std::index_sequence<__indices...>) const \ { \ diff --git a/libstdc++-v3/include/tr2/dynamic_bitset b/libstdc++-v3/include/tr2/dynamic_bitset index f76c8faf6e3..4f7a9bc9452 100644 --- a/libstdc++-v3/include/tr2/dynamic_bitset +++ b/libstdc++-v3/include/tr2/dynamic_bitset @@ -34,10 +34,9 @@ #include <limits> #include <vector> #include <string> -#include <memory> // For std::allocator -#include <bits/functexcept.h> // For invalid_argument, out_of_range, - // overflow_error -#include <iosfwd> +#include <istream> +#include <bits/functexcept.h> +#include <bits/stl_algo.h> // For fill #include <bits/cxxabi_forced.h> namespace std _GLIBCXX_VISIBILITY(default) @@ -76,41 +75,48 @@ namespace tr2 std::vector<block_type, allocator_type> _M_w; explicit - __dynamic_bitset_base(const allocator_type& __alloc = allocator_type()) + __dynamic_bitset_base(const allocator_type& __alloc) : _M_w(__alloc) { } - explicit - __dynamic_bitset_base(__dynamic_bitset_base&& __b) - { this->_M_w.swap(__b._M_w); } + __dynamic_bitset_base() = default; + __dynamic_bitset_base(const __dynamic_bitset_base&) = default; + __dynamic_bitset_base(__dynamic_bitset_base&& __b) = default; + __dynamic_bitset_base& operator=(const __dynamic_bitset_base&) = default; + __dynamic_bitset_base& operator=(__dynamic_bitset_base&&) = default; + ~__dynamic_bitset_base() = default; explicit __dynamic_bitset_base(size_type __nbits, unsigned long long __val = 0ULL, const allocator_type& __alloc = allocator_type()) - : _M_w(__nbits / _S_bits_per_block - + (__nbits % _S_bits_per_block > 0), - __val, __alloc) + : _M_w(__nbits / _S_bits_per_block + (__nbits % _S_bits_per_block > 0), + block_type(0), __alloc) { - unsigned long long __mask = ~static_cast<block_type>(0); - size_t __n = std::min(this->_M_w.size(), - sizeof(unsigned long long) / sizeof(block_type)); - for (size_t __i = 0; __i < __n; ++__i) + if (__nbits < std::numeric_limits<decltype(__val)>::digits) + __val &= ~(-1ULL << __nbits); + if (__val == 0) + return; + + if _GLIBCXX17_CONSTEXPR (sizeof(__val) == sizeof(block_type)) + _M_w[0] = __val; + else { - this->_M_w[__i] = (__val & __mask) >> (__i * _S_bits_per_block); - __mask <<= _S_bits_per_block; + const size_t __n + = std::min(_M_w.size(), sizeof(__val) / sizeof(block_type)); + for (size_t __i = 0; __val && __i < __n; ++__i) + { + _M_w[__i] = static_cast<block_type>(__val); + __val >>= _S_bits_per_block; + } } } void - _M_assign(const __dynamic_bitset_base& __b) - { this->_M_w = __b._M_w; } - - void - _M_swap(__dynamic_bitset_base& __b) + _M_swap(__dynamic_bitset_base& __b) noexcept { this->_M_w.swap(__b._M_w); } void - _M_clear() + _M_clear() noexcept { this->_M_w.clear(); } void @@ -129,7 +135,7 @@ namespace tr2 } allocator_type - _M_get_allocator() const + _M_get_allocator() const noexcept { return this->_M_w.get_allocator(); } static size_type @@ -149,23 +155,23 @@ namespace tr2 { return (static_cast<block_type>(1)) << _S_whichbit(__pos); } block_type& - _M_getword(size_type __pos) + _M_getword(size_type __pos) noexcept { return this->_M_w[_S_whichword(__pos)]; } block_type - _M_getword(size_type __pos) const + _M_getword(size_type __pos) const noexcept { return this->_M_w[_S_whichword(__pos)]; } block_type& - _M_hiword() + _M_hiword() noexcept { return this->_M_w[_M_w.size() - 1]; } block_type - _M_hiword() const + _M_hiword() const noexcept { return this->_M_w[_M_w.size() - 1]; } void - _M_do_and(const __dynamic_bitset_base& __x) + _M_do_and(const __dynamic_bitset_base& __x) noexcept { if (__x._M_w.size() == this->_M_w.size()) for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -175,7 +181,7 @@ namespace tr2 } void - _M_do_or(const __dynamic_bitset_base& __x) + _M_do_or(const __dynamic_bitset_base& __x) noexcept { if (__x._M_w.size() == this->_M_w.size()) for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -185,7 +191,7 @@ namespace tr2 } void - _M_do_xor(const __dynamic_bitset_base& __x) + _M_do_xor(const __dynamic_bitset_base& __x) noexcept { if (__x._M_w.size() == this->_M_w.size()) for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -195,7 +201,7 @@ namespace tr2 } void - _M_do_dif(const __dynamic_bitset_base& __x) + _M_do_dif(const __dynamic_bitset_base& __x) noexcept { if (__x._M_w.size() == this->_M_w.size()) for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -211,28 +217,27 @@ namespace tr2 _M_do_right_shift(size_t __shift); void - _M_do_flip() + _M_do_flip() noexcept { for (size_t __i = 0; __i < this->_M_w.size(); ++__i) this->_M_w[__i] = ~this->_M_w[__i]; } void - _M_do_set() + _M_do_set() noexcept { for (size_t __i = 0; __i < this->_M_w.size(); ++__i) - this->_M_w[__i] = ~static_cast<block_type>(0); + this->_M_w[__i] = static_cast<block_type>(-1); } void - _M_do_reset() + _M_do_reset() noexcept { - for (size_t __i = 0; __i < this->_M_w.size(); ++__i) - this->_M_w[__i] = static_cast<block_type>(0); + std::fill(_M_w.begin(), _M_w.end(), static_cast<block_type>(0)); } bool - _M_is_equal(const __dynamic_bitset_base& __x) const + _M_is_equal(const __dynamic_bitset_base& __x) const noexcept { if (__x._M_w.size() == this->_M_w.size()) { @@ -246,7 +251,7 @@ namespace tr2 } bool - _M_is_less(const __dynamic_bitset_base& __x) const + _M_is_less(const __dynamic_bitset_base& __x) const noexcept { if (__x._M_w.size() == this->_M_w.size()) { @@ -264,17 +269,17 @@ namespace tr2 } size_t - _M_are_all_aux() const + _M_are_all_aux() const noexcept { for (size_t __i = 0; __i < this->_M_w.size() - 1; ++__i) - if (_M_w[__i] != ~static_cast<block_type>(0)) + if (_M_w[__i] != static_cast<block_type>(-1)) return 0; return ((this->_M_w.size() - 1) * _S_bits_per_block + __builtin_popcountll(this->_M_hiword())); } bool - _M_is_any() const + _M_is_any() const noexcept { for (size_t __i = 0; __i < this->_M_w.size(); ++__i) if (this->_M_w[__i] != static_cast<block_type>(0)) @@ -283,7 +288,7 @@ namespace tr2 } bool - _M_is_subset_of(const __dynamic_bitset_base& __b) + _M_is_subset_of(const __dynamic_bitset_base& __b) noexcept { if (__b._M_w.size() == this->_M_w.size()) { @@ -297,7 +302,7 @@ namespace tr2 } bool - _M_is_proper_subset_of(const __dynamic_bitset_base& __b) const + _M_is_proper_subset_of(const __dynamic_bitset_base& __b) const noexcept { if (this->is_subset_of(__b)) { @@ -311,7 +316,7 @@ namespace tr2 } size_t - _M_do_count() const + _M_do_count() const noexcept { size_t __result = 0; for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -357,6 +362,7 @@ namespace tr2 * * See N2050, * Proposal to Add a Dynamically Sizeable Bitset to the Standard Library. + * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2050.pdf * * In the general unoptimized case, storage is allocated in * word-sized blocks. Let B be the number of bits in a word, then @@ -435,7 +441,7 @@ namespace tr2 { size_type __shift = this->_M_Nb % bits_per_block; if (__shift > 0) - this->_M_hiword() &= ~((~static_cast<block_type>(0)) << __shift); + this->_M_hiword() &= block_type(~(block_type(-1) << __shift)); } // Set the unused bits in the uppermost word. @@ -444,22 +450,22 @@ namespace tr2 { size_type __shift = this->_M_Nb % bits_per_block; if (__shift > 0) - this->_M_hiword() |= ((~static_cast<block_type>(0)) << __shift); + this->_M_hiword() |= block_type(block_type(-1) << __shift); } /** * These versions of single-bit set, reset, flip, and test * do no range checking. */ - dynamic_bitset<_WordT, _Alloc>& - _M_unchecked_set(size_type __pos) + dynamic_bitset& + _M_unchecked_set(size_type __pos) noexcept { this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); return *this; } - dynamic_bitset<_WordT, _Alloc>& - _M_unchecked_set(size_type __pos, int __val) + dynamic_bitset& + _M_unchecked_set(size_type __pos, int __val) noexcept { if (__val) this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); @@ -468,26 +474,26 @@ namespace tr2 return *this; } - dynamic_bitset<_WordT, _Alloc>& - _M_unchecked_reset(size_type __pos) + dynamic_bitset& + _M_unchecked_reset(size_type __pos) noexcept { this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); return *this; } - dynamic_bitset<_WordT, _Alloc>& - _M_unchecked_flip(size_type __pos) + dynamic_bitset& + _M_unchecked_flip(size_type __pos) noexcept { this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos); return *this; } bool - _M_unchecked_test(size_type __pos) const + _M_unchecked_test(size_type __pos) const noexcept { return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos)) != static_cast<_WordT>(0)); } - size_type _M_Nb; + size_type _M_Nb = 0; public: /** @@ -511,22 +517,16 @@ namespace tr2 block_type *_M_wp; size_type _M_bpos; - // left undefined - reference(); - public: - reference(dynamic_bitset& __b, size_type __pos) + reference(dynamic_bitset& __b, size_type __pos) noexcept { this->_M_wp = &__b._M_getword(__pos); this->_M_bpos = _Base::_S_whichbit(__pos); } - ~reference() - { } - // For b[i] = __x; reference& - operator=(bool __x) + operator=(bool __x) noexcept { if (__x) *this->_M_wp |= _Base::_S_maskbit(this->_M_bpos); @@ -537,7 +537,7 @@ namespace tr2 // For b[i] = b[__j]; reference& - operator=(const reference& __j) + operator=(const reference& __j) noexcept { if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos))) *this->_M_wp |= _Base::_S_maskbit(this->_M_bpos); @@ -548,16 +548,16 @@ namespace tr2 // Flips the bit bool - operator~() const + operator~() const noexcept { return (*(_M_wp) & _Base::_S_maskbit(this->_M_bpos)) == 0; } // For __x = b[i]; - operator bool() const + operator bool() const noexcept { return (*(this->_M_wp) & _Base::_S_maskbit(this->_M_bpos)) != 0; } // For b[i].flip(); reference& - flip() + flip() noexcept { *this->_M_wp ^= _Base::_S_maskbit(this->_M_bpos); return *this; @@ -569,10 +569,14 @@ namespace tr2 typedef bool const_reference; // 23.3.5.1 constructors: + + /// All bits set to zero. + dynamic_bitset() = default; + /// All bits set to zero. explicit - dynamic_bitset(const allocator_type& __alloc = allocator_type()) - : _Base(__alloc), _M_Nb(0) + dynamic_bitset(const allocator_type& __alloc) + : _Base(__alloc) { } /// Initial bits bitwise-copied from a single word (others set to zero). @@ -585,7 +589,7 @@ namespace tr2 dynamic_bitset(initializer_list<block_type> __il, const allocator_type& __alloc = allocator_type()) - : _Base(__alloc), _M_Nb(0) + : _Base(__alloc) { this->append(__il); } /** @@ -609,8 +613,7 @@ namespace tr2 __n = std::basic_string<_CharT, _Traits, _Alloc1>::npos, _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'), const allocator_type& __alloc = allocator_type()) - : _Base(__alloc), - _M_Nb(0) // Watch for npos. + : _Base(__alloc) { if (__pos > __str.size()) __throw_out_of_range(__N("dynamic_bitset::bitset initial position " @@ -619,8 +622,7 @@ namespace tr2 // Watch for npos. this->_M_Nb = (__n > __str.size() ? __str.size() - __pos : __n); this->resize(this->_M_Nb); - this->_M_copy_from_string(__str, __pos, __n, - _CharT('0'), _CharT('1')); + this->_M_copy_from_string(__str, __pos, __n); } /** @@ -633,61 +635,42 @@ namespace tr2 explicit dynamic_bitset(const char* __str, const allocator_type& __alloc = allocator_type()) - : _Base(__alloc) + : _Base(__builtin_strlen(__str), 0ULL, __alloc), + _M_Nb(__builtin_strlen(__str)) { - size_t __len = 0; - if (__str) - while (__str[__len] != '\0') - ++__len; - this->resize(__len); - this->_M_copy_from_ptr<char,std::char_traits<char>> - (__str, __len, 0, __len, '0', '1'); + this->_M_copy_from_ptr(__str, _M_Nb, 0, _M_Nb); } - /** - * @brief Copy constructor. - */ - dynamic_bitset(const dynamic_bitset& __b) - : _Base(__b), _M_Nb(__b.size()) - { } + /// Copy constructor. + dynamic_bitset(const dynamic_bitset&) = default; - /** - * @brief Move constructor. - */ - dynamic_bitset(dynamic_bitset&& __b) - : _Base(std::forward<_Base>(__b)), _M_Nb(__b.size()) - { } + /// Move constructor. + dynamic_bitset(dynamic_bitset&& __b) noexcept + : _Base(std::move(__b)), _M_Nb(__b._M_Nb) + { __b.clear(); } - /** - * @brief Swap with another bitset. - */ + /// Swap with another bitset. void - swap(dynamic_bitset& __b) + swap(dynamic_bitset& __b) noexcept { this->_M_swap(__b); std::swap(this->_M_Nb, __b._M_Nb); } - /** - * @brief Assignment. - */ - dynamic_bitset& - operator=(const dynamic_bitset& __b) - { - if (&__b != this) - { - this->_M_assign(__b); - this->_M_Nb = __b._M_Nb; - } - } + /// Copy assignment operator. + dynamic_bitset& operator=(const dynamic_bitset&) = default; - /** - * @brief Move assignment. - */ + /// Move assignment operator. dynamic_bitset& operator=(dynamic_bitset&& __b) + noexcept(std::is_nothrow_move_assignable<_Base>::value) { - this->swap(__b); + static_cast<_Base&>(*this) = static_cast<_Base&&>(__b); + _M_Nb = __b._M_Nb; + if _GLIBCXX17_CONSTEXPR (std::is_nothrow_move_assignable<_Base>::value) + __b._M_Nb = 0; + else if (get_allocator() == __b.get_allocator()) + __b._M_Nb = 0; return *this; } @@ -695,7 +678,7 @@ namespace tr2 * @brief Return the allocator for the bitset. */ allocator_type - get_allocator() const + get_allocator() const noexcept { return this->_M_get_allocator(); } /** @@ -733,6 +716,8 @@ namespace tr2 this->_M_unchecked_set(this->_M_Nb, __bit); } + // XXX why is there no pop_back() member in the proposal? + /** * @brief Append a block. */ @@ -769,36 +754,36 @@ namespace tr2 * * These should be self-explanatory. */ - dynamic_bitset<_WordT, _Alloc>& - operator&=(const dynamic_bitset<_WordT, _Alloc>& __rhs) + dynamic_bitset& + operator&=(const dynamic_bitset& __rhs) { this->_M_do_and(__rhs); return *this; } - dynamic_bitset<_WordT, _Alloc>& - operator&=(dynamic_bitset<_WordT, _Alloc>&& __rhs) + dynamic_bitset& + operator&=(dynamic_bitset&& __rhs) { this->_M_do_and(std::move(__rhs)); return *this; } - dynamic_bitset<_WordT, _Alloc>& - operator|=(const dynamic_bitset<_WordT, _Alloc>& __rhs) + dynamic_bitset& + operator|=(const dynamic_bitset& __rhs) { this->_M_do_or(__rhs); return *this; } - dynamic_bitset<_WordT, _Alloc>& - operator^=(const dynamic_bitset<_WordT, _Alloc>& __rhs) + dynamic_bitset& + operator^=(const dynamic_bitset& __rhs) { this->_M_do_xor(__rhs); return *this; } - dynamic_bitset<_WordT, _Alloc>& - operator-=(const dynamic_bitset<_WordT, _Alloc>& __rhs) + dynamic_bitset& + operator-=(const dynamic_bitset& __rhs) { this->_M_do_dif(__rhs); return *this; @@ -812,7 +797,7 @@ namespace tr2 * * These should be self-explanatory. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& operator<<=(size_type __pos) { if (__builtin_expect(__pos < this->_M_Nb, 1)) @@ -825,7 +810,7 @@ namespace tr2 return *this; } - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& operator>>=(size_type __pos) { if (__builtin_expect(__pos < this->_M_Nb, 1)) @@ -843,7 +828,7 @@ namespace tr2 /** * @brief Sets every bit to true. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& set() { this->_M_do_set(); @@ -857,7 +842,7 @@ namespace tr2 * @param __val Either true or false, defaults to true. * @throw std::out_of_range If @a __pos is bigger the size of the %set. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& set(size_type __pos, bool __val = true) { if (__pos >= _M_Nb) @@ -868,7 +853,7 @@ namespace tr2 /** * @brief Sets every bit to false. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& reset() { this->_M_do_reset(); @@ -882,7 +867,7 @@ namespace tr2 * * Same as writing @c set(__pos, false). */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& reset(size_type __pos) { if (__pos >= _M_Nb) @@ -893,7 +878,7 @@ namespace tr2 /** * @brief Toggles every bit to its opposite value. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& flip() { this->_M_do_flip(); @@ -906,7 +891,7 @@ namespace tr2 * @param __pos The index of the bit. * @throw std::out_of_range If @a __pos is bigger the size of the %set. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& flip(size_type __pos) { if (__pos >= _M_Nb) @@ -915,7 +900,7 @@ namespace tr2 } /// See the no-argument flip(). - dynamic_bitset<_WordT, _Alloc> + dynamic_bitset operator~() const { return dynamic_bitset<_WordT, _Alloc>(*this).flip(); } @@ -977,19 +962,23 @@ namespace tr2 } // Helper functions for string operations. - template<typename _CharT, typename _Traits> + template<typename _Traits = std::char_traits<char>, + typename _CharT = typename _Traits::char_type> void _M_copy_from_ptr(const _CharT*, size_t, size_t, size_t, - _CharT, _CharT); + _CharT __zero = _CharT('0'), + _CharT __one = _CharT('1')); template<typename _CharT, typename _Traits, typename _Alloc1> void - _M_copy_from_string(const std::basic_string<_CharT, - _Traits, _Alloc1>& __str, size_t __pos, size_t __n, + _M_copy_from_string(const basic_string<_CharT, _Traits, _Alloc1>& __str, + size_t __pos, size_t __n, _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) - { _M_copy_from_ptr<_CharT, _Traits>(__str.data(), __str.size(), - __pos, __n, __zero, __one); } + { + _M_copy_from_ptr<_Traits>(__str.data(), __str.size(), __pos, __n, + __zero, __one); + } template<typename _CharT, typename _Traits, typename _Alloc1> void @@ -1064,13 +1053,13 @@ namespace tr2 //@{ /// Self-explanatory. - dynamic_bitset<_WordT, _Alloc> + dynamic_bitset operator<<(size_type __pos) const - { return dynamic_bitset<_WordT, _Alloc>(*this) <<= __pos; } + { return dynamic_bitset(*this) <<= __pos; } - dynamic_bitset<_WordT, _Alloc> + dynamic_bitset operator>>(size_type __pos) const - { return dynamic_bitset<_WordT, _Alloc>(*this) >>= __pos; } + { return dynamic_bitset(*this) >>= __pos; } //@} /** @@ -1101,14 +1090,14 @@ namespace tr2 { return this->_M_is_proper_subset_of(__b); } friend bool - operator==(const dynamic_bitset<_WordT, _Alloc>& __lhs, - const dynamic_bitset<_WordT, _Alloc>& __rhs) - { return __lhs._M_is_equal(__rhs); } + operator==(const dynamic_bitset& __lhs, + const dynamic_bitset& __rhs) noexcept + { return __lhs._M_Nb == __rhs._M_Nb && __lhs._M_is_equal(__rhs); } friend bool - operator<(const dynamic_bitset<_WordT, _Alloc>& __lhs, - const dynamic_bitset<_WordT, _Alloc>& __rhs) - { return __lhs._M_is_less(__rhs); } + operator<(const dynamic_bitset& __lhs, + const dynamic_bitset& __rhs) noexcept + { return __lhs._M_is_less(__rhs) || __lhs._M_Nb < __rhs._M_Nb; } }; template<typename _WordT, typename _Alloc> diff --git a/libstdc++-v3/include/tr2/dynamic_bitset.tcc b/libstdc++-v3/include/tr2/dynamic_bitset.tcc index 6632403b499..76e75ad64a6 100644 --- a/libstdc++-v3/include/tr2/dynamic_bitset.tcc +++ b/libstdc++-v3/include/tr2/dynamic_bitset.tcc @@ -174,7 +174,7 @@ namespace tr2 // Definitions of non-inline member functions. template<typename _WordT, typename _Alloc> - template<typename _CharT, typename _Traits> + template<typename _Traits, typename _CharT> void dynamic_bitset<_WordT, _Alloc>:: _M_copy_from_ptr(const _CharT* __str, size_t __len, |