diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-13 20:44:06 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-13 20:44:06 +0000 |
commit | 82fe3c603e68f05ff811ad7f100278cb4d049898 (patch) | |
tree | 5652a60d71016c53bbb0aac1ef275c4b2a0d0115 /libstdc++-v3/include/experimental | |
parent | de03b9ecbc54eee8a48e8bfc7d235fb66d0f64c9 (diff) | |
download | gcc-82fe3c603e68f05ff811ad7f100278cb4d049898.tar.gz |
Post-Urbana updates to Library Fundamentals v1.
* include/experimental/any (any): Remove allocator support and update
feature-testing macro.
* include/experimental/functional: Update feature-testing macro.
* include/experimental/optional (optional::_M_get()): Add constexpr.
(optional::operator*(), optional::value()): Overload and add
ref-qualifiers. Update feature-testing macro.
* include/experimental/string_view (basic_string_view::clear): Remove
and update feature-testing macro.
* testsuite/experimental/any/cons/3.cc: Remove.
* testsuite/experimental/any/cons/4.cc: Remove.
* testsuite/experimental/any/misc/any_cast.cc: Remove allocator tests.
* testsuite/experimental/any/misc/any_cast_neg.cc: Adjust dg-error.
* testsuite/experimental/string_view/capacity/1.cc: Don't test clear().
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218709 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/experimental')
-rw-r--r-- | libstdc++-v3/include/experimental/any | 175 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/functional | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/optional | 52 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/string_view | 9 |
4 files changed, 45 insertions, 193 deletions
diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any index 87dd7a16019..3af925fd50d 100644 --- a/libstdc++-v3/include/experimental/any +++ b/libstdc++-v3/include/experimental/any @@ -36,11 +36,9 @@ #else #include <typeinfo> -#include <memory> +#include <new> #include <utility> #include <type_traits> -#include <bits/alloc_traits.h> -#include <bits/uses_allocator.h> namespace std _GLIBCXX_VISIBILITY(default) { @@ -60,7 +58,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ -#define __cpp_lib_experimental_any 201402 +#define __cpp_lib_experimental_any 201411 /** * @brief Exception class thrown by a failed @c any_cast @@ -96,7 +94,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::aligned_storage<sizeof(_M_ptr), sizeof(_M_ptr)>::type _M_buffer; }; - template<typename _Tp, typename _Safe = is_nothrow_copy_constructible<_Tp>, + template<typename _Tp, typename _Safe = is_nothrow_move_constructible<_Tp>, bool _Fits = (sizeof(_Tp) <= sizeof(_Storage))> using _Internal = std::integral_constant<bool, _Safe::value && _Fits>; @@ -111,19 +109,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Manager_internal<_Tp>, _Manager_external<_Tp>>; -#if __cpp_rtti - // When RTTI is disabled __any_caster assumes the manager is either - // _Manager_internal or _Manager_external, so this type must not be used. - template<typename _Tp, typename _Alloc> - struct _Manager_alloc; // creates contained object using an allocator - - template<typename _Tp, typename _Alloc, - typename _TpAlloc = __alloc_rebind<_Alloc, _Tp>> - using _ManagerAlloc = conditional_t<_Internal<_Tp>::value, - _Manager_internal<_Tp>, - _Manager_alloc<_Tp, _TpAlloc>>; -#endif - template<typename _Tp, typename _Decayed = decay_t<_Tp>> using _Decay = enable_if_t<!is_same<_Decayed, any>::value, _Decayed>; @@ -165,35 +150,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "The contained object must be CopyConstructible"); } - /// Allocator-extended default constructor (the allocator is ignored). - template <typename _Allocator> - any(allocator_arg_t, const _Allocator&) noexcept : any() { } - -#if __cpp_rtti - /// Construct with a copy of @p __value as the contained object. - template <typename _Allocator, typename _ValueType, - typename _Tp = _Decay<_ValueType>, - typename _Mgr = _ManagerAlloc<_Tp, _Allocator>> - any(allocator_arg_t, const _Allocator& __a, _ValueType&& __value) - : _M_manager(&_Mgr::_S_manage), - _M_storage(_Mgr::_S_alloc(__a, std::forward<_ValueType>(__value))) - { - static_assert(is_copy_constructible<_Tp>::value, - "The contained object must be CopyConstructible"); - } -#endif - - /* TODO: implement this somehow - /// Allocator-extended copy constructor. - template <class _Allocator> - any(allocator_arg_t, const _Allocator& __a, const any& __other); - */ - - /// Allocator-extended move constructor (the allocator is ignored). - template <typename _Allocator> - any(allocator_arg_t, const _Allocator&, any&& __other) noexcept - : any(std::move(__other)) { } - /// Destructor, calls @c clear() ~any() { clear(); } @@ -281,13 +237,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> friend void* __any_caster(const any* __any) { -#if __cpp_rtti - if (__any->type() != typeid(_Tp)) - return nullptr; -#else if (__any->_M_manager != &_Manager<decay_t<_Tp>>::_S_manage) return nullptr; -#endif _Arg __arg; __any->_M_manager(_Op_access, __any, &__arg); return __arg._M_obj; @@ -334,29 +285,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __storage; } }; - -#if __cpp_rtti - // Manage external contained object using an allocator - template<typename _Tp, typename _Alloc> - struct _Manager_alloc - { - static_assert(std::is_same<_Tp, typename _Alloc::value_type>::value, - "Allocator's value_type is correct"); - - // Type that holds contained object and allocator - struct _Data; - - using _Traits = typename std::allocator_traits<_Alloc>::template - rebind_traits<_Data>; - - static void - _S_manage(_Op __which, const any* __anyp, _Arg* __arg); - - template<typename _Up> - static _Storage - _S_alloc(const _Alloc& __a, _Up&& __value); - }; -#endif }; /// Exchange the states of two @c any objects. @@ -446,71 +374,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } // @} -#if __cpp_rtti - template<typename _Tp, typename _Alloc> - struct any::_Manager_alloc<_Tp, _Alloc>::_Data - { - using _Traits = std::allocator_traits<_Alloc>; - - std::tuple<__gnu_cxx::__aligned_buffer<_Tp>, _Alloc> _M_data; - - _Alloc& _M_alloc() { return std::get<1>(_M_data); } - const _Alloc& _M_alloc() const { return std::get<1>(_M_data); } - - _Tp* _M_obj() { return std::get<0>(_M_data)._M_ptr(); } - const _Tp* _M_obj() const { return std::get<0>(_M_data)._M_ptr(); } - - template<typename _Up> - _Data(const _Alloc& __a, _Up&& __val) : _M_data(nullptr, __a) - { - this->_M_construct(std::__use_alloc<_Tp, _Alloc, _Up&&>(_M_alloc()), - std::forward<_Up>(__val)); - } - - ~_Data() { _Traits::destroy(_M_alloc(), _M_obj()); } - - template<typename _Up> - void - _M_construct(__uses_alloc0, _Up&& __val) - { - _Traits::construct(_M_alloc(), _M_obj(), - std::forward<_Up>(__val)); - } - - template<typename _Up> - void - _M_construct(__uses_alloc1<_Alloc> __a, _Up&& __val) - { - _Traits::construct(_M_alloc(), _M_obj(), - std::allocator_arg, *__a._M_a, - std::forward<_Up>(__val)); - } - - template<typename _Up> - void - _M_construct(__uses_alloc2<_Alloc> __a, _Up&& __val) - { - _Traits::construct(_M_alloc(), _M_obj(), - std::forward<_Up>(__val), *__a._M_a); - } - }; - - template<typename _Tp, typename _Alloc> - template<typename _Up> - any::_Storage - any::_Manager_alloc<_Tp, _Alloc>:: - _S_alloc(const _Alloc& __a, _Up&& __value) - { - typename _Traits::allocator_type __a2(__a); - auto __guard = std::__allocate_guarded(__a2); - any::_Storage __storage; - __storage._M_ptr = __guard.get(); - ::new(__storage._M_ptr) _Data{__a, std::forward<_Up>(__value)}; - __guard = nullptr; - return __storage; - } -#endif - template<typename _Tp> void any::_Manager_internal<_Tp>:: @@ -563,38 +426,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } -#if __cpp_rtti - template<typename _Tp, typename _Alloc> - void - any::_Manager_alloc<_Tp, _Alloc>:: - _S_manage(_Op __which, const any* __any, _Arg* __arg) - { - // The contained object is at _M_storage._M_ptr->_M_obj() - auto __ptr = static_cast<const _Data*>(__any->_M_storage._M_ptr); - switch (__which) - { - case _Op_access: - __arg->_M_obj = const_cast<_Tp*>(__ptr->_M_obj()); - break; - case _Op_get_type_info: - __arg->_M_typeinfo = &typeid(_Tp); - break; - case _Op_clone: - __arg->_M_any->_M_storage - = _S_alloc(__ptr->_M_alloc(), *__ptr->_M_obj()); - break; - case _Op_destroy: - { - using _Alloc2 = typename _Traits::allocator_type; - _Alloc2 __a(__ptr->_M_alloc()); - __allocated_ptr<_Alloc2> __guard{__a, const_cast<_Data*>(__ptr)}; - __ptr->~_Data(); - } - break; - } - } -#endif - // @} group any _GLIBCXX_END_NAMESPACE_VERSION } // namespace fundamentals_v1 diff --git a/libstdc++-v3/include/experimental/functional b/libstdc++-v3/include/experimental/functional index 4ecc6a5fb6d..5202e89cd61 100644 --- a/libstdc++-v3/include/experimental/functional +++ b/libstdc++-v3/include/experimental/functional @@ -61,7 +61,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> constexpr int is_placeholder_v = std::is_placeholder<_Tp>::value; -#define __cpp_lib_experimental_boyer_moore_searching 201402 +#define __cpp_lib_experimental_boyer_moore_searching 201411 // Searchers diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional index 2d3127a7b1d..e87a1d4c652 100644 --- a/libstdc++-v3/include/experimental/optional +++ b/libstdc++-v3/include/experimental/optional @@ -67,7 +67,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ -#define __cpp_lib_experimental_optional 201406 +#define __cpp_lib_experimental_optional 201411 // All subsequent [X.Y.n] references are against n3793. @@ -290,7 +290,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return this->_M_engaged; } // The _M_get operations have _M_engaged as a precondition. - _Tp& + constexpr _Tp& _M_get() noexcept { return _M_payload; } @@ -574,18 +574,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return std::__addressof(this->_M_get()); } constexpr const _Tp& - operator*() const + operator*() const& { return this->_M_get(); } - _Tp& - operator*() + constexpr _Tp& + operator*()& { return this->_M_get(); } + constexpr _Tp&& + operator*()&& + { return std::move(this->_M_get()); } + + constexpr const _Tp&& + operator*() const&& + { return std::move(this->_M_get()); } + constexpr explicit operator bool() const noexcept { return this->_M_is_engaged(); } constexpr const _Tp& - value() const + value() const& { return this->_M_is_engaged() ? this->_M_get() @@ -594,14 +602,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION this->_M_get()); } - _Tp& - value() + constexpr _Tp& + value()& { - if (this->_M_is_engaged()) - return this->_M_get(); + return this->_M_is_engaged() + ? this->_M_get() + : (__throw_bad_optional_access("Attempt to access value of a " + "disengaged optional object"), + this->_M_get()); + } - __throw_bad_optional_access("Attempt to access value of a " - "disengaged optional object"); + constexpr _Tp&& + value()&& + { + return this->_M_is_engaged() + ? std::move(this->_M_get()) + : (__throw_bad_optional_access("Attempt to access value of a " + "disengaged optional object"), + std::move(this->_M_get())); + } + + constexpr const _Tp&& + value() const&& + { + return this->_M_is_engaged() + ? std::move(this->_M_get()) + : (__throw_bad_optional_access("Attempt to access value of a " + "disengaged optional object"), + std::move(this->_M_get())); } template<typename _Up> diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view index 320d72db321..6e1dd5a9ee1 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -50,7 +50,7 @@ inline namespace fundamentals_v1 { _GLIBCXX_BEGIN_NAMESPACE_VERSION -#define __cpp_lib_experimental_string_view 201402 +#define __cpp_lib_experimental_string_view 201411 /** * @class basic_string_view <experimental/string_view> @@ -219,13 +219,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // [string.view.modifiers], modifiers: void - clear() noexcept - { - this->_M_len = 0; - this->_M_str = nullptr; - } - - void remove_prefix(size_type __n) { _GLIBCXX_DEBUG_ASSERT(this->_M_len >= __n); |