diff options
28 files changed, 1 insertions, 2575 deletions
diff --git a/libcxx/include/experimental/any b/libcxx/include/experimental/any index 083a2909033..1dcdd0f25ec 100644 --- a/libcxx/include/experimental/any +++ b/libcxx/include/experimental/any @@ -8,585 +8,4 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP_EXPERIMENTAL_ANY -#define _LIBCPP_EXPERIMENTAL_ANY - -/* - experimental/any synopsis - -namespace std { -namespace experimental { -inline namespace fundamentals_v1 { - - class bad_any_cast : public bad_cast - { - public: - virtual const char* what() const noexcept; - }; - - class any - { - public: - - // 6.3.1 any construct/destruct - any() noexcept; - - any(const any& other); - any(any&& other) noexcept; - - template <class ValueType> - any(ValueType&& value); - - ~any(); - - // 6.3.2 any assignments - any& operator=(const any& rhs); - any& operator=(any&& rhs) noexcept; - - template <class ValueType> - any& operator=(ValueType&& rhs); - - // 6.3.3 any modifiers - void clear() noexcept; - void swap(any& rhs) noexcept; - - // 6.3.4 any observers - bool empty() const noexcept; - const type_info& type() const noexcept; - }; - - // 6.4 Non-member functions - void swap(any& x, any& y) noexcept; - - template<class ValueType> - ValueType any_cast(const any& operand); - template<class ValueType> - ValueType any_cast(any& operand); - template<class ValueType> - ValueType any_cast(any&& operand); - - template<class ValueType> - const ValueType* any_cast(const any* operand) noexcept; - template<class ValueType> - ValueType* any_cast(any* operand) noexcept; - -} // namespace fundamentals_v1 -} // namespace experimental -} // namespace std - -*/ - -#include <experimental/__config> -#include <memory> -#include <new> -#include <typeinfo> -#include <type_traits> -#include <cstdlib> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_LFTS - -class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast -{ -public: - virtual const char* what() const _NOEXCEPT; -}; - -#if _LIBCPP_STD_VER > 11 // C++ > 11 - -_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE -_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST -void __throw_bad_any_cast() -{ -#ifndef _LIBCPP_NO_EXCEPTIONS - throw bad_any_cast(); -#else - _VSTD::abort(); -#endif -} - -// Forward declarations -class any; - -template <class _ValueType> -typename add_pointer<typename add_const<_ValueType>::type>::type -_LIBCPP_INLINE_VISIBILITY -any_cast(any const *) _NOEXCEPT; - -template <class _ValueType> -typename add_pointer<_ValueType>::type -_LIBCPP_INLINE_VISIBILITY -any_cast(any *) _NOEXCEPT; - -namespace __any_imp -{ - typedef typename aligned_storage<3*sizeof(void*), alignment_of<void*>::value>::type - _Buffer; - - template <class _Tp> - struct _IsSmallObject - : public integral_constant<bool - , sizeof(_Tp) <= sizeof(_Buffer) - && alignment_of<_Buffer>::value - % alignment_of<_Tp>::value == 0 - && is_nothrow_move_constructible<_Tp>::value - > - {}; - - enum class _Action - { - _Destroy, - _Copy, - _Move, - _Get, - _TypeInfo - }; - - template <class _Tp> - struct _SmallHandler; - - template <class _Tp> - struct _LargeHandler; - - template <class _Tp> - using _Handler = typename conditional<_IsSmallObject<_Tp>::value - , _SmallHandler<_Tp> - , _LargeHandler<_Tp> - >::type; - template <class _ValueType> - using _EnableIfNotAny = typename - enable_if< - !is_same<typename decay<_ValueType>::type, any>::value - >::type; - -} // namespace __any_imp - -class any -{ -public: - // 6.3.1 any construct/destruct - _LIBCPP_INLINE_VISIBILITY - any() _NOEXCEPT : __h(nullptr) {} - - _LIBCPP_INLINE_VISIBILITY - any(any const & __other) : __h(nullptr) - { - if (__other.__h) __other.__call(_Action::_Copy, this); - } - - _LIBCPP_INLINE_VISIBILITY - any(any && __other) _NOEXCEPT : __h(nullptr) - { - if (__other.__h) __other.__call(_Action::_Move, this); - } - - template < - class _ValueType - , class = __any_imp::_EnableIfNotAny<_ValueType> - > - _LIBCPP_INLINE_VISIBILITY - any(_ValueType && __value); - - _LIBCPP_INLINE_VISIBILITY - ~any() - { - this->clear(); - } - - // 6.3.2 any assignments - _LIBCPP_INLINE_VISIBILITY - any & operator=(any const & __rhs) - { - any(__rhs).swap(*this); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - any & operator=(any && __rhs) _NOEXCEPT - { - any(_VSTD::move(__rhs)).swap(*this); - return *this; - } - - template < - class _ValueType - , class = __any_imp::_EnableIfNotAny<_ValueType> - > - _LIBCPP_INLINE_VISIBILITY - any & operator=(_ValueType && __rhs); - - // 6.3.3 any modifiers - _LIBCPP_INLINE_VISIBILITY - void clear() _NOEXCEPT - { - if (__h) this->__call(_Action::_Destroy); - } - - _LIBCPP_INLINE_VISIBILITY - void swap(any & __rhs) _NOEXCEPT; - - // 6.3.4 any observers - _LIBCPP_INLINE_VISIBILITY - bool empty() const _NOEXCEPT - { - return __h == nullptr; - } - -#if !defined(_LIBCPP_NO_RTTI) - _LIBCPP_INLINE_VISIBILITY - const type_info & type() const _NOEXCEPT - { - if (__h) { - return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo)); - } else { - return typeid(void); - } - } -#endif - -private: - typedef __any_imp::_Action _Action; - - typedef void* (*_HandleFuncPtr)(_Action, any const *, any *, const type_info *); - - union _Storage - { - void * __ptr; - __any_imp::_Buffer __buf; - }; - - _LIBCPP_ALWAYS_INLINE - void * __call(_Action __a, any * __other = nullptr, - type_info const * __info = nullptr) const - { - return __h(__a, this, __other, __info); - } - - _LIBCPP_ALWAYS_INLINE - void * __call(_Action __a, any * __other = nullptr, - type_info const * __info = nullptr) - { - return __h(__a, this, __other, __info); - } - - template <class> - friend struct __any_imp::_SmallHandler; - template <class> - friend struct __any_imp::_LargeHandler; - - template <class _ValueType> - friend typename add_pointer<typename add_const<_ValueType>::type>::type - any_cast(any const *) _NOEXCEPT; - - template <class _ValueType> - friend typename add_pointer<_ValueType>::type - any_cast(any *) _NOEXCEPT; - - _HandleFuncPtr __h; - _Storage __s; -}; - -namespace __any_imp -{ - - template <class _Tp> - struct _LIBCPP_TEMPLATE_VIS _SmallHandler - { - _LIBCPP_INLINE_VISIBILITY - static void* __handle(_Action __act, any const * __this, any * __other, - type_info const * __info) - { - switch (__act) - { - case _Action::_Destroy: - __destroy(const_cast<any &>(*__this)); - return nullptr; - case _Action::_Copy: - __copy(*__this, *__other); - return nullptr; - case _Action::_Move: - __move(const_cast<any &>(*__this), *__other); - return nullptr; - case _Action::_Get: - return __get(const_cast<any &>(*__this), __info); - case _Action::_TypeInfo: - return __type_info(); - } - } - - template <class _Up> - _LIBCPP_INLINE_VISIBILITY - static void __create(any & __dest, _Up && __v) - { - ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Up>(__v)); - __dest.__h = &_SmallHandler::__handle; - } - - private: - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void __destroy(any & __this) - { - _Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf)); - __value.~_Tp(); - __this.__h = nullptr; - } - - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void __copy(any const & __this, any & __dest) - { - _SmallHandler::__create(__dest, *static_cast<_Tp const *>( - static_cast<void const *>(&__this.__s.__buf))); - } - - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void __move(any & __this, any & __dest) - { - _SmallHandler::__create(__dest, _VSTD::move( - *static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf)))); - __destroy(__this); - } - - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void* __get(any & __this, type_info const * __info) - { -#if !defined(_LIBCPP_NO_RTTI) - if (typeid(_Tp) == *__info) { - return static_cast<void*>(&__this.__s.__buf); - } - return nullptr; -#else - return static_cast<void*>(&__this.__s.__buf); -#endif - } - - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void* __type_info() - { -#if !defined(_LIBCPP_NO_RTTI) - return const_cast<void*>(static_cast<void const *>(&typeid(_Tp))); -#else - return nullptr; -#endif - } - }; - - template <class _Tp> - struct _LIBCPP_TEMPLATE_VIS _LargeHandler - { - _LIBCPP_INLINE_VISIBILITY - static void* __handle(_Action __act, any const * __this, any * __other, - type_info const * __info) - { - switch (__act) - { - case _Action::_Destroy: - __destroy(const_cast<any &>(*__this)); - return nullptr; - case _Action::_Copy: - __copy(*__this, *__other); - return nullptr; - case _Action::_Move: - __move(const_cast<any &>(*__this), *__other); - return nullptr; - case _Action::_Get: - return __get(const_cast<any &>(*__this), __info); - case _Action::_TypeInfo: - return __type_info(); - } - } - - template <class _Up> - _LIBCPP_INLINE_VISIBILITY - static void __create(any & __dest, _Up && __v) - { - typedef allocator<_Tp> _Alloc; - typedef __allocator_destructor<_Alloc> _Dp; - _Alloc __a; - unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Up>(__v)); - __dest.__s.__ptr = __hold.release(); - __dest.__h = &_LargeHandler::__handle; - } - - private: - - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void __destroy(any & __this) - { - delete static_cast<_Tp*>(__this.__s.__ptr); - __this.__h = nullptr; - } - - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void __copy(any const & __this, any & __dest) - { - _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr)); - } - - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void __move(any & __this, any & __dest) - { - __dest.__s.__ptr = __this.__s.__ptr; - __dest.__h = &_LargeHandler::__handle; - __this.__h = nullptr; - } - - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void* __get(any & __this, type_info const * __info) - { -#if !defined(_LIBCPP_NO_RTTI) - if (typeid(_Tp) == *__info) { - return static_cast<void*>(__this.__s.__ptr); - } - return nullptr; -#else - return static_cast<void*>(__this.__s.__ptr); -#endif - } - - _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY - static void* __type_info() - { -#if !defined(_LIBCPP_NO_RTTI) - return const_cast<void*>(static_cast<void const *>(&typeid(_Tp))); -#else - return nullptr; -#endif - } - }; - -} // namespace __any_imp - - -template <class _ValueType, class> -any::any(_ValueType && __v) : __h(nullptr) -{ - typedef typename decay<_ValueType>::type _Tp; - static_assert(is_copy_constructible<_Tp>::value, - "_ValueType must be CopyConstructible."); - typedef __any_imp::_Handler<_Tp> _HandlerType; - _HandlerType::__create(*this, _VSTD::forward<_ValueType>(__v)); -} - -template <class _ValueType, class> -any & any::operator=(_ValueType && __v) -{ - typedef typename decay<_ValueType>::type _Tp; - static_assert(is_copy_constructible<_Tp>::value, - "_ValueType must be CopyConstructible."); - any(_VSTD::forward<_ValueType>(__v)).swap(*this); - return *this; -} - -inline -void any::swap(any & __rhs) _NOEXCEPT -{ - if (__h && __rhs.__h) { - any __tmp; - __rhs.__call(_Action::_Move, &__tmp); - this->__call(_Action::_Move, &__rhs); - __tmp.__call(_Action::_Move, this); - } - else if (__h) { - this->__call(_Action::_Move, &__rhs); - } - else if (__rhs.__h) { - __rhs.__call(_Action::_Move, this); - } -} - -// 6.4 Non-member functions - -inline _LIBCPP_INLINE_VISIBILITY -void swap(any & __lhs, any & __rhs) _NOEXCEPT -{ - __lhs.swap(__rhs); -} - -template <class _ValueType> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST -_ValueType any_cast(any const & __v) -{ - static_assert( - is_reference<_ValueType>::value - || is_copy_constructible<_ValueType>::value, - "_ValueType is required to be a reference or a CopyConstructible type."); - typedef typename add_const<typename remove_reference<_ValueType>::type>::type - _Tp; - _Tp * __tmp = any_cast<_Tp>(&__v); - if (__tmp == nullptr) - __throw_bad_any_cast(); - return *__tmp; -} - -template <class _ValueType> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST -_ValueType any_cast(any & __v) -{ - static_assert( - is_reference<_ValueType>::value - || is_copy_constructible<_ValueType>::value, - "_ValueType is required to be a reference or a CopyConstructible type."); - typedef typename remove_reference<_ValueType>::type _Tp; - _Tp * __tmp = any_cast<_Tp>(&__v); - if (__tmp == nullptr) - __throw_bad_any_cast(); - return *__tmp; -} - -template <class _ValueType> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST -_ValueType any_cast(any && __v) -{ - static_assert( - is_reference<_ValueType>::value - || is_copy_constructible<_ValueType>::value, - "_ValueType is required to be a reference or a CopyConstructible type."); - typedef typename remove_reference<_ValueType>::type _Tp; - _Tp * __tmp = any_cast<_Tp>(&__v); - if (__tmp == nullptr) - __throw_bad_any_cast(); - return *__tmp; -} - -template <class _ValueType> -inline -typename add_pointer<typename add_const<_ValueType>::type>::type -any_cast(any const * __any) _NOEXCEPT -{ - static_assert(!is_reference<_ValueType>::value, - "_ValueType may not be a reference."); - return any_cast<_ValueType>(const_cast<any *>(__any)); -} - -template <class _ValueType> -typename add_pointer<_ValueType>::type -any_cast(any * __any) _NOEXCEPT -{ - using __any_imp::_Action; - static_assert(!is_reference<_ValueType>::value, - "_ValueType may not be a reference."); - typedef typename add_pointer<_ValueType>::type _ReturnType; - if (__any && __any->__h) { - - return static_cast<_ReturnType>( - __any->__call(_Action::_Get, nullptr, -#if !defined(_LIBCPP_NO_RTTI) - &typeid(_ValueType) -#else - nullptr -#endif - )); - - } - return nullptr; -} - -#endif // _LIBCPP_STD_VER > 11 - -_LIBCPP_END_NAMESPACE_LFTS - -#endif // _LIBCPP_EXPERIMENTAL_ANY +#error "<experimental/any> has been removed. Use <any> instead." diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap index de1d507bfa9..d25e6190707 100644 --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -493,10 +493,6 @@ module std [system] { header "experimental/algorithm" export * } - module any { - header "experimental/any" - export * - } module chrono { header "experimental/chrono" export * diff --git a/libcxx/src/any.cpp b/libcxx/src/any.cpp index 45b2337eb35..96855202991 100644 --- a/libcxx/src/any.cpp +++ b/libcxx/src/any.cpp @@ -8,16 +8,9 @@ //===----------------------------------------------------------------------===// #include "any" -#include "experimental/any" namespace std { const char* bad_any_cast::what() const _NOEXCEPT { return "bad any cast"; } } - -_LIBCPP_BEGIN_NAMESPACE_LFTS -const char* bad_any_cast::what() const _NOEXCEPT { - return "bad any cast"; -} -_LIBCPP_END_NAMESPACE_LFTS diff --git a/libcxx/test/libcxx/double_include.sh.cpp b/libcxx/test/libcxx/double_include.sh.cpp index fe728f778ae..60a574a82c3 100644 --- a/libcxx/test/libcxx/double_include.sh.cpp +++ b/libcxx/test/libcxx/double_include.sh.cpp @@ -135,7 +135,6 @@ // experimental headers #if __cplusplus >= 201103L #include <experimental/algorithm> -#include <experimental/any> #include <experimental/chrono> #if defined(__cpp_coroutines) #include <experimental/coroutine> diff --git a/libcxx/test/libcxx/experimental/any/size_and_alignment.pass.cpp b/libcxx/test/libcxx/experimental/any/size_and_alignment.pass.cpp deleted file mode 100644 index b7db5402047..00000000000 --- a/libcxx/test/libcxx/experimental/any/size_and_alignment.pass.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// Check that the size and alignment of any are what we expect. - -#include <experimental/any> - -int main() -{ - using std::experimental::any; - static_assert(sizeof(any) == sizeof(void*)*4, ""); - static_assert(alignof(any) == alignof(void*), ""); -} diff --git a/libcxx/test/libcxx/experimental/any/small_type.pass.cpp b/libcxx/test/libcxx/experimental/any/small_type.pass.cpp deleted file mode 100644 index 96754126c99..00000000000 --- a/libcxx/test/libcxx/experimental/any/small_type.pass.cpp +++ /dev/null @@ -1,114 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// Check that the size and alignment of any are what we expect. - -#include <experimental/any> -#include "experimental_any_helpers.h" - -constexpr std::size_t BufferSize = (sizeof(void*) * 3); -constexpr std::size_t BufferAlignment = alignof(void*); -// Clang doesn't like "alignof(BufferAlignment * 2)" due to PR13986. -// So we create "DoubleBufferAlignment" instead. -constexpr std::size_t DoubleBufferAlignment = BufferAlignment * 2; - -class SmallThrowsDtor -{ -public: - SmallThrowsDtor() {} - SmallThrowsDtor(SmallThrowsDtor const &) noexcept {} - SmallThrowsDtor(SmallThrowsDtor &&) noexcept {} - ~SmallThrowsDtor() noexcept(false) {} -}; - - -struct alignas(1) MaxSizeType { - char buff[BufferSize]; -}; - -struct alignas(BufferAlignment) MaxAlignType { -}; - -struct alignas(BufferAlignment) MaxSizeAndAlignType { - char buff[BufferSize]; -}; - - -struct alignas(1) OverSizeType { - char buff[BufferSize + 1]; -}; - -struct alignas(DoubleBufferAlignment) OverAlignedType { -}; - -struct alignas(DoubleBufferAlignment) OverSizeAndAlignedType { - char buff[BufferSize + 1]; -}; - -int main() -{ - using std::experimental::any; - using std::experimental::__any_imp::_IsSmallObject; - static_assert(_IsSmallObject<small>::value, ""); - static_assert(_IsSmallObject<void*>::value, ""); - static_assert(!_IsSmallObject<SmallThrowsDtor>::value, ""); - static_assert(!_IsSmallObject<large>::value, ""); - { - // Check a type that meets the size requirement *exactly* and has - // a lesser alignment requirement is considered small. - typedef MaxSizeType T; - static_assert(sizeof(T) == BufferSize, ""); - static_assert(alignof(T) < BufferAlignment, ""); - static_assert(_IsSmallObject<T>::value, ""); - } - { - // Check a type that meets the alignment requirement *exactly* and has - // a lesser size is considered small. - typedef MaxAlignType T; - static_assert(sizeof(T) < BufferSize, ""); - static_assert(alignof(T) == BufferAlignment, ""); - static_assert(_IsSmallObject<T>::value, ""); - } - { - // Check a type that meets the size and alignment requirements *exactly* - // is considered small. - typedef MaxSizeAndAlignType T; - static_assert(sizeof(T) == BufferSize, ""); - static_assert(alignof(T) == BufferAlignment, ""); - static_assert(_IsSmallObject<T>::value, ""); - } - { - // Check a type that meets the alignment requirements but is over-sized - // is not considered small. - typedef OverSizeType T; - static_assert(sizeof(T) > BufferSize, ""); - static_assert(alignof(T) < BufferAlignment, ""); - static_assert(!_IsSmallObject<T>::value, ""); - } - { - // Check a type that meets the size requirements but is over-aligned - // is not considered small. - typedef OverAlignedType T; - static_assert(sizeof(T) < BufferSize, ""); - static_assert(alignof(T) > BufferAlignment, ""); - static_assert(!_IsSmallObject<T>::value, ""); - } - { - // Check a type that exceeds both the size an alignment requirements - // is not considered small. - typedef OverSizeAndAlignedType T; - static_assert(sizeof(T) > BufferSize, ""); - static_assert(alignof(T) > BufferAlignment, ""); - static_assert(!_IsSmallObject<T>::value, ""); - } -} diff --git a/libcxx/test/libcxx/experimental/any/version.pass.cpp b/libcxx/test/libcxx/experimental/any/version.pass.cpp deleted file mode 100644 index 611d65027b1..00000000000 --- a/libcxx/test/libcxx/experimental/any/version.pass.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <experimental/any> - -#include <experimental/any> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} diff --git a/libcxx/test/libcxx/min_max_macros.sh.cpp b/libcxx/test/libcxx/min_max_macros.sh.cpp index 978ff90803f..7411ca2b38c 100644 --- a/libcxx/test/libcxx/min_max_macros.sh.cpp +++ b/libcxx/test/libcxx/min_max_macros.sh.cpp @@ -237,8 +237,6 @@ TEST_MACROS(); #if __cplusplus >= 201103L #include <experimental/algorithm> TEST_MACROS(); -#include <experimental/any> -TEST_MACROS(); #include <experimental/chrono> TEST_MACROS(); #include <experimental/deque> diff --git a/libcxx/test/std/experimental/any/any.class/any.assign/copy.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.assign/copy.pass.cpp deleted file mode 100644 index 0b9d71e5f70..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.assign/copy.pass.cpp +++ /dev/null @@ -1,199 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx - -// <experimental/any> - -// any& operator=(any const &); - -// Test copy assignment - -#include <experimental/any> -#include <cassert> - -#include "experimental_any_helpers.h" -#include "count_new.hpp" -#include "test_macros.h" - -using std::experimental::any; -using std::experimental::any_cast; - -template <class LHS, class RHS> -void test_copy_assign() { - assert(LHS::count == 0); - assert(RHS::count == 0); - LHS::reset(); - RHS::reset(); - { - any lhs(LHS(1)); - any const rhs(RHS(2)); - - assert(LHS::count == 1); - assert(RHS::count == 1); - assert(RHS::copied == 0); - - lhs = rhs; - - assert(RHS::copied == 1); - assert(LHS::count == 0); - assert(RHS::count == 2); - - assertContains<RHS>(lhs, 2); - assertContains<RHS>(rhs, 2); - } - assert(LHS::count == 0); - assert(RHS::count == 0); -} - -template <class LHS> -void test_copy_assign_empty() { - assert(LHS::count == 0); - LHS::reset(); - { - any lhs; - any const rhs(LHS(42)); - - assert(LHS::count == 1); - assert(LHS::copied == 0); - - lhs = rhs; - - assert(LHS::copied == 1); - assert(LHS::count == 2); - - assertContains<LHS>(lhs, 42); - assertContains<LHS>(rhs, 42); - } - assert(LHS::count == 0); - LHS::reset(); - { - any lhs(LHS(1)); - any const rhs; - - assert(LHS::count == 1); - assert(LHS::copied == 0); - - lhs = rhs; - - assert(LHS::copied == 0); - assert(LHS::count == 0); - - assertEmpty<LHS>(lhs); - assertEmpty(rhs); - } - assert(LHS::count == 0); -} - -void test_copy_assign_self() { - // empty - { - any a; - a = a; - assertEmpty(a); - assert(globalMemCounter.checkOutstandingNewEq(0)); - } - assert(globalMemCounter.checkOutstandingNewEq(0)); - // small - { - any a((small(1))); - assert(small::count == 1); - - a = a; - - assert(small::count == 1); - assertContains<small>(a, 1); - assert(globalMemCounter.checkOutstandingNewEq(0)); - } - assert(small::count == 0); - assert(globalMemCounter.checkOutstandingNewEq(0)); - // large - { - any a(large(1)); - assert(large::count == 1); - - a = a; - - assert(large::count == 1); - assertContains<large>(a, 1); - assert(globalMemCounter.checkOutstandingNewEq(1)); - } - assert(large::count == 0); - assert(globalMemCounter.checkOutstandingNewEq(0)); -} - -template <class Tp> -void test_copy_assign_throws() -{ -#if !defined(TEST_HAS_NO_EXCEPTIONS) - auto try_throw = - [](any& lhs, any const& rhs) { - try { - lhs = rhs; - assert(false); - } catch (my_any_exception const &) { - // do nothing - } catch (...) { - assert(false); - } - }; - // const lvalue to empty - { - any lhs; - any const rhs((Tp(1))); - assert(Tp::count == 1); - - try_throw(lhs, rhs); - - assert(Tp::count == 1); - assertEmpty<Tp>(lhs); - assertContains<Tp>(rhs); - } - { - any lhs((small(2))); - any const rhs((Tp(1))); - assert(small::count == 1); - assert(Tp::count == 1); - - try_throw(lhs, rhs); - - assert(small::count == 1); - assert(Tp::count == 1); - assertContains<small>(lhs, 2); - assertContains<Tp>(rhs); - } - { - any lhs((large(2))); - any const rhs((Tp(1))); - assert(large::count == 1); - assert(Tp::count == 1); - - try_throw(lhs, rhs); - - assert(large::count == 1); - assert(Tp::count == 1); - assertContains<large>(lhs, 2); - assertContains<Tp>(rhs); - } -#endif -} - -int main() { - test_copy_assign<small1, small2>(); - test_copy_assign<large1, large2>(); - test_copy_assign<small, large>(); - test_copy_assign<large, small>(); - test_copy_assign_empty<small>(); - test_copy_assign_empty<large>(); - test_copy_assign_self(); - test_copy_assign_throws<small_throws_on_copy>(); - test_copy_assign_throws<large_throws_on_copy>(); -} diff --git a/libcxx/test/std/experimental/any/any.class/any.assign/move.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.assign/move.pass.cpp deleted file mode 100644 index 72351aeae68..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.assign/move.pass.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx - -// <experimental/any> - -// any& operator=(any &&); - -// Test move assignment. - -#include <experimental/any> -#include <cassert> - -#include "experimental_any_helpers.h" -#include "test_macros.h" - -using std::experimental::any; -using std::experimental::any_cast; - -template <class LHS, class RHS> -void test_move_assign() { - assert(LHS::count == 0); - assert(RHS::count == 0); - { - LHS const s1(1); - any a(s1); - RHS const s2(2); - any a2(s2); - - assert(LHS::count == 2); - assert(RHS::count == 2); - - a = std::move(a2); - - assert(LHS::count == 1); - assert(RHS::count == 2); - - assertContains<RHS>(a, 2); - assertEmpty<RHS>(a2); - } - assert(LHS::count == 0); - assert(RHS::count == 0); -} - -template <class LHS> -void test_move_assign_empty() { - assert(LHS::count == 0); - { - any a; - any a2((LHS(1))); - - assert(LHS::count == 1); - - a = std::move(a2); - - assert(LHS::count == 1); - - assertContains<LHS>(a, 1); - assertEmpty<LHS>(a2); - } - assert(LHS::count == 0); - { - any a((LHS(1))); - any a2; - - assert(LHS::count == 1); - - a = std::move(a2); - - assert(LHS::count == 0); - - assertEmpty<LHS>(a); - assertEmpty(a2); - } - assert(LHS::count == 0); -} - -void test_move_assign_noexcept() { - any a1; - any a2; - static_assert( - noexcept(a1 = std::move(a2)) - , "any & operator=(any &&) must be noexcept" - ); -} - -int main() { - test_move_assign_noexcept(); - test_move_assign<small1, small2>(); - test_move_assign<large1, large2>(); - test_move_assign<small, large>(); - test_move_assign<large, small>(); - test_move_assign_empty<small>(); - test_move_assign_empty<large>(); -} diff --git a/libcxx/test/std/experimental/any/any.class/any.assign/value.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.assign/value.pass.cpp deleted file mode 100644 index cd4646fb5fd..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.assign/value.pass.cpp +++ /dev/null @@ -1,179 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx - -// <experimental/any> - -// any& operator=(any const &); - -// Test value copy and move assignment. - -#include <experimental/any> -#include <cassert> - -#include "experimental_any_helpers.h" -#include "count_new.hpp" -#include "test_macros.h" - -using std::experimental::any; -using std::experimental::any_cast; - -template <class LHS, class RHS> -void test_assign_value() { - assert(LHS::count == 0); - assert(RHS::count == 0); - LHS::reset(); - RHS::reset(); - { - any lhs(LHS(1)); - any const rhs(RHS(2)); - - assert(LHS::count == 1); - assert(RHS::count == 1); - assert(RHS::copied == 0); - - lhs = rhs; - - assert(RHS::copied == 1); - assert(LHS::count == 0); - assert(RHS::count == 2); - - assertContains<RHS>(lhs, 2); - assertContains<RHS>(rhs, 2); - } - assert(LHS::count == 0); - assert(RHS::count == 0); - LHS::reset(); - RHS::reset(); - { - any lhs(LHS(1)); - any rhs(RHS(2)); - - assert(LHS::count == 1); - assert(RHS::count == 1); - assert(RHS::moved == 1); - - lhs = std::move(rhs); - - assert(RHS::moved >= 1); - assert(RHS::copied == 0); - assert(LHS::count == 0); - assert(RHS::count == 1); - - assertContains<RHS>(lhs, 2); - assertEmpty<RHS>(rhs); - } - assert(LHS::count == 0); - assert(RHS::count == 0); -} - -template <class RHS> -void test_assign_value_empty() { - assert(RHS::count == 0); - RHS::reset(); - { - any lhs; - RHS rhs(42); - assert(RHS::count == 1); - assert(RHS::copied == 0); - - lhs = rhs; - - assert(RHS::count == 2); - assert(RHS::copied == 1); - assert(RHS::moved >= 0); - assertContains<RHS>(lhs, 42); - } - assert(RHS::count == 0); - RHS::reset(); - { - any lhs; - RHS rhs(42); - assert(RHS::count == 1); - assert(RHS::moved == 0); - - lhs = std::move(rhs); - - assert(RHS::count == 2); - assert(RHS::copied == 0); - assert(RHS::moved >= 1); - assertContains<RHS>(lhs, 42); - } - assert(RHS::count == 0); - RHS::reset(); -} - - -template <class Tp, bool Move = false> -void test_assign_throws() { -#if !defined(TEST_HAS_NO_EXCEPTIONS) - auto try_throw= - [](any& lhs, auto&& rhs) { - try { - Move ? lhs = std::move(rhs) - : lhs = rhs; - assert(false); - } catch (my_any_exception const &) { - // do nothing - } catch (...) { - assert(false); - } - }; - // const lvalue to empty - { - any lhs; - Tp rhs(1); - assert(Tp::count == 1); - - try_throw(lhs, rhs); - - assert(Tp::count == 1); - assertEmpty<Tp>(lhs); - } - { - any lhs((small(2))); - Tp rhs(1); - assert(small::count == 1); - assert(Tp::count == 1); - - try_throw(lhs, rhs); - - assert(small::count == 1); - assert(Tp::count == 1); - assertContains<small>(lhs, 2); - } - { - any lhs((large(2))); - Tp rhs(1); - assert(large::count == 1); - assert(Tp::count == 1); - - try_throw(lhs, rhs); - - assert(large::count == 1); - assert(Tp::count == 1); - assertContains<large>(lhs, 2); - } -#endif -} - -int main() { - test_assign_value<small1, small2>(); - test_assign_value<large1, large2>(); - test_assign_value<small, large>(); - test_assign_value<large, small>(); - test_assign_value_empty<small>(); - test_assign_value_empty<large>(); - test_assign_throws<small_throws_on_copy>(); - test_assign_throws<large_throws_on_copy>(); - test_assign_throws<throws_on_move, /* Move = */ true>(); -} diff --git a/libcxx/test/std/experimental/any/any.class/any.assign/value_non_copyable_assign.fail.cpp b/libcxx/test/std/experimental/any/any.class/any.assign/value_non_copyable_assign.fail.cpp deleted file mode 100644 index 7d2d33d63cf..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.assign/value_non_copyable_assign.fail.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// template <class Value> -// any& operator=(Value &&); - -// Instantiate the value assignment operator with a non-copyable type. - -#include <experimental/any> - -class non_copyable -{ - non_copyable(non_copyable const &); - -public: - non_copyable() {} - non_copyable(non_copyable &&) {} -}; - -int main() -{ - using namespace std::experimental; - non_copyable nc; - any a; - a = static_cast<non_copyable &&>(nc); // expected-error-re@experimental/any:* 2 {{static_assert failed{{.*}} "_ValueType must be CopyConstructible."}} - // expected-error@experimental/any:* {{calling a private constructor of class 'non_copyable'}} - -} diff --git a/libcxx/test/std/experimental/any/any.class/any.cons/copy.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.cons/copy.pass.cpp deleted file mode 100644 index d477394c0b9..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.cons/copy.pass.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx - -// <experimental/any> - -// any(any const &); - -#include <experimental/any> -#include <cassert> - -#include "experimental_any_helpers.h" -#include "count_new.hpp" -#include "test_macros.h" - -using std::experimental::any; -using std::experimental::any_cast; - -template <class Type> -void test_copy_throws() { -#if !defined(TEST_HAS_NO_EXCEPTIONS) - assert(Type::count == 0); - { - any const a((Type(42))); - assert(Type::count == 1); - try { - any const a2(a); - assert(false); - } catch (my_any_exception const &) { - // do nothing - } catch (...) { - assert(false); - } - assert(Type::count == 1); - assertContains<Type>(a, 42); - } - assert(Type::count == 0); -#endif -} - -void test_copy_empty() { - DisableAllocationGuard g; ((void)g); // No allocations should occur. - any a1; - any a2(a1); - - assertEmpty(a1); - assertEmpty(a2); -} - -template <class Type> -void test_copy() -{ - // Copying small types should not perform any allocations. - DisableAllocationGuard g(isSmallType<Type>()); ((void)g); - assert(Type::count == 0); - Type::reset(); - { - any a((Type(42))); - assert(Type::count == 1); - assert(Type::copied == 0); - - any a2(a); - - assert(Type::copied == 1); - assert(Type::count == 2); - assertContains<Type>(a, 42); - assertContains<Type>(a, 42); - - // Modify a and check that a2 is unchanged - modifyValue<Type>(a, -1); - assertContains<Type>(a, -1); - assertContains<Type>(a2, 42); - - // modify a2 and check that a is unchanged - modifyValue<Type>(a2, 999); - assertContains<Type>(a, -1); - assertContains<Type>(a2, 999); - - // clear a and check that a2 is unchanged - a.clear(); - assertEmpty(a); - assertContains<Type>(a2, 999); - } - assert(Type::count == 0); -} - -int main() { - test_copy<small>(); - test_copy<large>(); - test_copy_empty(); - test_copy_throws<small_throws_on_copy>(); - test_copy_throws<large_throws_on_copy>(); -} diff --git a/libcxx/test/std/experimental/any/any.class/any.cons/default.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.cons/default.pass.cpp deleted file mode 100644 index 3839e3afc81..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.cons/default.pass.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// any() noexcept; - -#include <experimental/any> -#include <type_traits> -#include <cassert> - -#include "experimental_any_helpers.h" -#include "count_new.hpp" - - -int main() -{ - using std::experimental::any; - { - static_assert( - std::is_nothrow_default_constructible<any>::value - , "Must be default constructible" - ); - } - { - DisableAllocationGuard g; ((void)g); - any const a; - assertEmpty(a); - } -} diff --git a/libcxx/test/std/experimental/any/any.class/any.cons/move.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.cons/move.pass.cpp deleted file mode 100644 index ef980ca5f22..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.cons/move.pass.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx - -// <experimental/any> - -// any(any &&) noexcept; - -#include <experimental/any> -#include <utility> -#include <type_traits> -#include <cassert> - -#include "experimental_any_helpers.h" -#include "count_new.hpp" -#include "test_macros.h" - -using std::experimental::any; -using std::experimental::any_cast; - -// Moves are always noexcept. The throws_on_move object -// must be stored dynamically so the pointer is moved and -// not the stored object. -void test_move_does_not_throw() -{ -#if !defined(TEST_HAS_NO_EXCEPTIONS) - assert(throws_on_move::count == 0); - { - throws_on_move v(42); - any a(v); - assert(throws_on_move::count == 2); - // No allocations should be performed after this point. - DisableAllocationGuard g; ((void)g); - try { - any const a2(std::move(a)); - assertEmpty(a); - assertContains<throws_on_move>(a2, 42); - } catch (...) { - assert(false); - } - assert(throws_on_move::count == 1); - assertEmpty(a); - } - assert(throws_on_move::count == 0); -#endif -} - -void test_move_empty() { - DisableAllocationGuard g; ((void)g); // no allocations should be performed. - - any a1; - any a2(std::move(a1)); - - assertEmpty(a1); - assertEmpty(a2); -} - -template <class Type> -void test_move() { - assert(Type::count == 0); - Type::reset(); - { - any a((Type(42))); - assert(Type::count == 1); - assert(Type::copied == 0); - assert(Type::moved == 1); - - // Moving should not perform allocations since it must be noexcept. - DisableAllocationGuard g; ((void)g); - - any a2(std::move(a)); - - assert(Type::moved >= 1); // zero or more move operations can be performed. - assert(Type::copied == 0); // no copies can be performed. - assert(Type::count == 1); - assertEmpty(a); // Moves are always destructive. - assertContains<Type>(a2, 42); - } - assert(Type::count == 0); -} - -int main() -{ - // noexcept test - { - static_assert( - std::is_nothrow_move_constructible<any>::value - , "any must be nothrow move constructible" - ); - } - test_move<small>(); - test_move<large>(); - test_move_empty(); - test_move_does_not_throw(); -} diff --git a/libcxx/test/std/experimental/any/any.class/any.cons/non_copyable_value.fail.cpp b/libcxx/test/std/experimental/any/any.class/any.cons/non_copyable_value.fail.cpp deleted file mode 100644 index c4f7568ec85..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.cons/non_copyable_value.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// any::any<Value>(Value &&) - -// Attempt to construct any with a non-copyable type. - -#include <experimental/any> - -class non_copyable -{ - non_copyable(non_copyable const &); - -public: - non_copyable() {} - non_copyable(non_copyable &&) {} -}; - -int main() -{ - using namespace std::experimental; - non_copyable nc; - any a(static_cast<non_copyable &&>(nc)); - // expected-error-re@experimental/any:* 1 {{static_assert failed{{.*}} "_ValueType must be CopyConstructible."}} - // expected-error@experimental/any:* 1 {{calling a private constructor of class 'non_copyable'}} -} diff --git a/libcxx/test/std/experimental/any/any.class/any.cons/value.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.cons/value.pass.cpp deleted file mode 100644 index d37990e6ca3..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.cons/value.pass.cpp +++ /dev/null @@ -1,118 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx - -// <experimental/any> - -// template <class Value> any(Value &&) - -// Test construction from a value. -// Concerns: -// --------- -// 1. The value is properly move/copied depending on the value category. -// 2. Both small and large values are properly handled. - - -#include <experimental/any> -#include <cassert> - -#include "experimental_any_helpers.h" -#include "count_new.hpp" -#include "test_macros.h" - -using std::experimental::any; -using std::experimental::any_cast; - -template <class Type> -void test_copy_value_throws() -{ -#if !defined(TEST_HAS_NO_EXCEPTIONS) - assert(Type::count == 0); - { - Type const t(42); - assert(Type::count == 1); - try { - any const a2(t); - assert(false); - } catch (my_any_exception const &) { - // do nothing - } catch (...) { - assert(false); - } - assert(Type::count == 1); - assert(t.value == 42); - } - assert(Type::count == 0); -#endif -} - -void test_move_value_throws() -{ -#if !defined(TEST_HAS_NO_EXCEPTIONS) - assert(throws_on_move::count == 0); - { - throws_on_move v; - assert(throws_on_move::count == 1); - try { - any const a(std::move(v)); - assert(false); - } catch (my_any_exception const &) { - // do nothing - } catch (...) { - assert(false); - } - assert(throws_on_move::count == 1); - } - assert(throws_on_move::count == 0); -#endif -} - -template <class Type> -void test_copy_move_value() { - // constructing from a small type should perform no allocations. - DisableAllocationGuard g(isSmallType<Type>()); ((void)g); - assert(Type::count == 0); - Type::reset(); - { - Type t(42); - assert(Type::count == 1); - - any a(t); - - assert(Type::count == 2); - assert(Type::copied == 1); - assert(Type::moved == 0); - assertContains<Type>(a, 42); - } - assert(Type::count == 0); - Type::reset(); - { - Type t(42); - assert(Type::count == 1); - - any a(std::move(t)); - - assert(Type::count == 2); - assert(Type::copied == 0); - assert(Type::moved == 1); - assertContains<Type>(a, 42); - } -} - - -int main() { - test_copy_move_value<small>(); - test_copy_move_value<large>(); - test_copy_value_throws<small_throws_on_copy>(); - test_copy_value_throws<large_throws_on_copy>(); - test_move_value_throws(); -} diff --git a/libcxx/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp deleted file mode 100644 index a19bd38f129..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp +++ /dev/null @@ -1,65 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx - -// <experimental/any> - -// any::clear() noexcept - -#include <experimental/any> -#include <cassert> - -#include "experimental_any_helpers.h" - -int main() -{ - using std::experimental::any; - using std::experimental::any_cast; - // empty - { - any a; - - // noexcept check - static_assert( - noexcept(a.clear()) - , "any.clear() must be noexcept" - ); - - assertEmpty(a); - - a.clear(); - - assertEmpty(a); - } - // small object - { - any a((small(1))); - assert(small::count == 1); - assertContains<small>(a, 1); - - a.clear(); - - assertEmpty<small>(a); - assert(small::count == 0); - } - // large object - { - any a(large(1)); - assert(large::count == 1); - assertContains<large>(a); - - a.clear(); - - assertEmpty<large>(a); - assert(large::count == 0); - } -} diff --git a/libcxx/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp deleted file mode 100644 index 8de582a6b76..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx - -// <experimental/any> - -// any::swap(any &) noexcept - -// Test swap(large, small) and swap(small, large) - -#include <experimental/any> -#include <cassert> - -#include "experimental_any_helpers.h" - -using std::experimental::any; -using std::experimental::any_cast; - -template <class LHS, class RHS> -void test_swap() { - assert(LHS::count == 0); - assert(RHS::count == 0); - { - any a1((LHS(1))); - any a2(RHS{2}); - assert(LHS::count == 1); - assert(RHS::count == 1); - - a1.swap(a2); - - assert(LHS::count == 1); - assert(RHS::count == 1); - - assertContains<RHS>(a1, 2); - assertContains<LHS>(a2, 1); - } - assert(LHS::count == 0); - assert(RHS::count == 0); - assert(LHS::copied == 0); - assert(RHS::copied == 0); -} - -template <class Tp> -void test_swap_empty() { - assert(Tp::count == 0); - { - any a1((Tp(1))); - any a2; - assert(Tp::count == 1); - - a1.swap(a2); - - assert(Tp::count == 1); - - assertContains<Tp>(a2, 1); - assertEmpty(a1); - } - assert(Tp::count == 0); - { - any a1((Tp(1))); - any a2; - assert(Tp::count == 1); - - a2.swap(a1); - - assert(Tp::count == 1); - - assertContains<Tp>(a2, 1); - assertEmpty(a1); - } - assert(Tp::count == 0); - assert(Tp::copied == 0); -} - -void test_noexcept() -{ - any a1; - any a2; - static_assert( - noexcept(a1.swap(a2)) - , "any::swap(any&) must be noexcept" - ); -} - -int main() -{ - test_noexcept(); - test_swap_empty<small>(); - test_swap_empty<large>(); - test_swap<small1, small2>(); - test_swap<large1, large2>(); - test_swap<small, large>(); - test_swap<large, small>(); -} diff --git a/libcxx/test/std/experimental/any/any.class/any.observers/empty.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.observers/empty.pass.cpp deleted file mode 100644 index bdf0d511b81..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.observers/empty.pass.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// any::empty() noexcept - -#include <experimental/any> -#include <cassert> - -#include "experimental_any_helpers.h" - -int main() -{ - using std::experimental::any; - // noexcept test - { - any a; - static_assert(noexcept(a.empty()), "any::empty() must be noexcept"); - } - // empty - { - any a; - assert(a.empty()); - - a.clear(); - assert(a.empty()); - - a = 42; - assert(!a.empty()); - } - // small object - { - small const s(1); - any a(s); - assert(!a.empty()); - - a.clear(); - assert(a.empty()); - - a = s; - assert(!a.empty()); - } - // large object - { - large const l(1); - any a(l); - assert(!a.empty()); - - a.clear(); - assert(a.empty()); - - a = l; - assert(!a.empty()); - } -} diff --git a/libcxx/test/std/experimental/any/any.class/any.observers/type.pass.cpp b/libcxx/test/std/experimental/any/any.class/any.observers/type.pass.cpp deleted file mode 100644 index 6d004840367..00000000000 --- a/libcxx/test/std/experimental/any/any.class/any.observers/type.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: libcpp-no-rtti - -// <experimental/any> - -// any::type() noexcept - -#include <experimental/any> -#include <cassert> -#include "experimental_any_helpers.h" - -int main() -{ - using std::experimental::any; - { - any const a; - assert(a.type() == typeid(void)); - static_assert(noexcept(a.type()), "any::type() must be noexcept"); - } - { - small const s(1); - any const a(s); - assert(a.type() == typeid(small)); - - } - { - large const l(1); - any const a(l); - assert(a.type() == typeid(large)); - } -} diff --git a/libcxx/test/std/experimental/any/any.class/nothing_to_do.pass.cpp b/libcxx/test/std/experimental/any/any.class/nothing_to_do.pass.cpp deleted file mode 100644 index c21f8a70168..00000000000 --- a/libcxx/test/std/experimental/any/any.class/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include <experimental/string_view> - -int main () {} diff --git a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/any_cast_pointer.pass.cpp b/libcxx/test/std/experimental/any/any.nonmembers/any.cast/any_cast_pointer.pass.cpp deleted file mode 100644 index 46ddbe5b05a..00000000000 --- a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/any_cast_pointer.pass.cpp +++ /dev/null @@ -1,146 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// template <class ValueType> -// ValueType const* any_cast(any const *) noexcept; -// -// template <class ValueType> -// ValueType * any_cast(any *) noexcept; - -#include <experimental/any> -#include <type_traits> -#include <cassert> - -#include "experimental_any_helpers.h" - -using std::experimental::any; -using std::experimental::any_cast; - -// Test that the operators are properly noexcept. -void test_cast_is_noexcept() { - any a; - static_assert(noexcept(any_cast<int>(&a)), ""); - - any const& ca = a; - static_assert(noexcept(any_cast<int>(&ca)), ""); -} - -// Test that the return type of any_cast is correct. -void test_cast_return_type() { - any a; - static_assert(std::is_same<decltype(any_cast<int>(&a)), int*>::value, ""); - static_assert(std::is_same<decltype(any_cast<int const>(&a)), int const*>::value, ""); - - any const& ca = a; - static_assert(std::is_same<decltype(any_cast<int>(&ca)), int const*>::value, ""); - static_assert(std::is_same<decltype(any_cast<int const>(&ca)), int const*>::value, ""); -} - -// Test that any_cast handles null pointers. -void test_cast_nullptr() { - any* a = nullptr; - assert(nullptr == any_cast<int>(a)); - assert(nullptr == any_cast<int const>(a)); - - any const* ca = nullptr; - assert(nullptr == any_cast<int>(ca)); - assert(nullptr == any_cast<int const>(ca)); -} - -// Test casting an empty object. -void test_cast_empty() { - { - any a; - assert(nullptr == any_cast<int>(&a)); - assert(nullptr == any_cast<int const>(&a)); - - any const& ca = a; - assert(nullptr == any_cast<int>(&ca)); - assert(nullptr == any_cast<int const>(&ca)); - } - // Create as non-empty, then make empty and run test. - { - any a(42); - a.clear(); - assert(nullptr == any_cast<int>(&a)); - assert(nullptr == any_cast<int const>(&a)); - - any const& ca = a; - assert(nullptr == any_cast<int>(&ca)); - assert(nullptr == any_cast<int const>(&ca)); - } -} - -template <class Type> -void test_cast() { - assert(Type::count == 0); - Type::reset(); - { - any a((Type(42))); - any const& ca = a; - assert(Type::count == 1); - assert(Type::copied == 0); - assert(Type::moved == 1); - - // Try a cast to a bad type. - // NOTE: Type cannot be an int. - assert(any_cast<int>(&a) == nullptr); - assert(any_cast<int const>(&a) == nullptr); - assert(any_cast<int const volatile>(&a) == nullptr); - - // Try a cast to the right type, but as a pointer. - assert(any_cast<Type*>(&a) == nullptr); - assert(any_cast<Type const*>(&a) == nullptr); - - // Check getting a unqualified type from a non-const any. - Type* v = any_cast<Type>(&a); - assert(v != nullptr); - assert(v->value == 42); - - // change the stored value and later check for the new value. - v->value = 999; - - // Check getting a const qualified type from a non-const any. - Type const* cv = any_cast<Type const>(&a); - assert(cv != nullptr); - assert(cv == v); - assert(cv->value == 999); - - // Check getting a unqualified type from a const any. - cv = any_cast<Type>(&ca); - assert(cv != nullptr); - assert(cv == v); - assert(cv->value == 999); - - // Check getting a const-qualified type from a const any. - cv = any_cast<Type const>(&ca); - assert(cv != nullptr); - assert(cv == v); - assert(cv->value == 999); - - // Check that no more objects were created, copied or moved. - assert(Type::count == 1); - assert(Type::copied == 0); - assert(Type::moved == 1); - } - assert(Type::count == 0); -} - -int main() { - test_cast_is_noexcept(); - test_cast_return_type(); - test_cast_nullptr(); - test_cast_empty(); - test_cast<small>(); - test_cast<large>(); -} diff --git a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp b/libcxx/test/std/experimental/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp deleted file mode 100644 index ca6d1de116e..00000000000 --- a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp +++ /dev/null @@ -1,312 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx - -// <experimental/any> - -// template <class ValueType> -// ValueType const any_cast(any const&); -// -// template <class ValueType> -// ValueType any_cast(any &); -// -// template <class ValueType> -// ValueType any_cast(any &&); - -#include <experimental/any> -#include <type_traits> -#include <cassert> - -#include "experimental_any_helpers.h" -#include "count_new.hpp" -#include "test_macros.h" - -using std::experimental::any; -using std::experimental::any_cast; -using std::experimental::bad_any_cast; - - -// Test that the operators are NOT marked noexcept. -void test_cast_is_not_noexcept() { - any a; - static_assert(!noexcept(any_cast<int>(static_cast<any&>(a))), ""); - static_assert(!noexcept(any_cast<int>(static_cast<any const&>(a))), ""); - static_assert(!noexcept(any_cast<int>(static_cast<any &&>(a))), ""); -} - -// Test that the return type of any_cast is correct. -void test_cast_return_type() { - any a; - static_assert(std::is_same<decltype(any_cast<int>(a)), int>::value, ""); - static_assert(std::is_same<decltype(any_cast<int const>(a)), int>::value, ""); - static_assert(std::is_same<decltype(any_cast<int&>(a)), int&>::value, ""); - static_assert(std::is_same<decltype(any_cast<int const&>(a)), int const&>::value, ""); - - //static_assert(std::is_same<decltype(any_cast<int&&>(a)), int&&>::value, ""); - //static_assert(std::is_same<decltype(any_cast<int const&&>(a)), int const&&>::value, ""); - - static_assert(std::is_same<decltype(any_cast<int>(std::move(a))), int>::value, ""); - static_assert(std::is_same<decltype(any_cast<int const>(std::move(a))), int>::value, ""); - static_assert(std::is_same<decltype(any_cast<int&>(std::move(a))), int&>::value, ""); - static_assert(std::is_same<decltype(any_cast<int const&>(std::move(a))), int const&>::value, ""); - - //static_assert(std::is_same<decltype(any_cast<int&&>(std::move(a))), int&&>::value, ""); - //static_assert(std::is_same<decltype(any_cast<int const&&>(std::move(a))), int const&&>::value, ""); - - any const& ca = a; - static_assert(std::is_same<decltype(any_cast<int>(ca)), int>::value, ""); - static_assert(std::is_same<decltype(any_cast<int const>(ca)), int>::value, ""); - static_assert(std::is_same<decltype(any_cast<int const&>(ca)), int const&>::value, ""); - - //static_assert(std::is_same<decltype(any_cast<int const&&>(ca)), int const&&>::value, ""); -} - -template <class Type, class ConstT = Type> -void checkThrows(any& a) -{ -#if !defined(TEST_HAS_NO_EXCEPTIONS) - try { - any_cast<Type>(a); - assert(false); - } catch (bad_any_cast const &) { - // do nothing - } catch (...) { - assert(false); - } - - try { - any_cast<ConstT>(static_cast<any const&>(a)); - assert(false); - } catch (bad_any_cast const &) { - // do nothing - } catch (...) { - assert(false); - } - - try { - any_cast<Type>(static_cast<any&&>(a)); - assert(false); - } catch (bad_any_cast const &) { - // do nothing - } catch (...) { - assert(false); - } -#else - ((void)a); -#endif -} - -void test_cast_empty() { - // None of these operations should allocate. - DisableAllocationGuard g; ((void)g); - any a; - checkThrows<int>(a); -} - -template <class Type> -void test_cast_to_reference() { - assert(Type::count == 0); - Type::reset(); - { - any a((Type(42))); - any const& ca = a; - assert(Type::count == 1); - assert(Type::copied == 0); - assert(Type::moved == 1); - - // Try a cast to a bad type. - // NOTE: Type cannot be an int. - checkThrows<int>(a); - checkThrows<int&, int const&>(a); - checkThrows<Type*, Type const*>(a); - checkThrows<Type const*>(a); - - // Check getting a type by reference from a non-const lvalue any. - { - Type& v = any_cast<Type&>(a); - assert(v.value == 42); - - Type const &cv = any_cast<Type const&>(a); - assert(&cv == &v); - } - // Check getting a type by reference from a const lvalue any. - { - Type const& v = any_cast<Type const&>(ca); - assert(v.value == 42); - - Type const &cv = any_cast<Type const&>(ca); - assert(&cv == &v); - } - // Check getting a type by reference from a non-const rvalue - { - Type& v = any_cast<Type&>(std::move(a)); - assert(v.value == 42); - - Type const &cv = any_cast<Type const&>(std::move(a)); - assert(&cv == &v); - } - // Check getting a type by reference from a const rvalue any. - { - Type const& v = any_cast<Type const&>(std::move(ca)); - assert(v.value == 42); - - Type const &cv = any_cast<Type const&>(std::move(ca)); - assert(&cv == &v); - } - - // Check that the original object hasn't been changed. - assertContains<Type>(a, 42); - - // Check that no objects have been created/copied/moved. - assert(Type::count == 1); - assert(Type::copied == 0); - assert(Type::moved == 1); - } - assert(Type::count == 0); -} - -template <class Type> -void test_cast_to_value() { - assert(Type::count == 0); - Type::reset(); - { - any a((Type(42))); - assert(Type::count == 1); - assert(Type::copied == 0); - assert(Type::moved == 1); - - // Try a cast to a bad type. - // NOTE: Type cannot be an int. - checkThrows<int>(a); - checkThrows<int&, int const&>(a); - checkThrows<Type*, Type const*>(a); - checkThrows<Type const*>(a); - - Type::reset(); // NOTE: reset does not modify Type::count - // Check getting Type by value from a non-const lvalue any. - // This should cause the non-const copy constructor to be called. - { - Type t = any_cast<Type>(a); - - assert(Type::count == 2); - assert(Type::copied == 1); - assert(Type::const_copied == 0); - assert(Type::non_const_copied == 1); - assert(Type::moved == 0); - assert(t.value == 42); - } - assert(Type::count == 1); - Type::reset(); - // Check getting const Type by value from a non-const lvalue any. - // This should cause the const copy constructor to be called. - { - Type t = any_cast<Type const>(a); - - assert(Type::count == 2); - assert(Type::copied == 1); - assert(Type::const_copied == 1); - assert(Type::non_const_copied == 0); - assert(Type::moved == 0); - assert(t.value == 42); - } - assert(Type::count == 1); - Type::reset(); - // Check getting Type by value from a non-const lvalue any. - // This should cause the const copy constructor to be called. - { - Type t = any_cast<Type>(static_cast<any const&>(a)); - - assert(Type::count == 2); - assert(Type::copied == 1); - assert(Type::const_copied == 1); - assert(Type::non_const_copied == 0); - assert(Type::moved == 0); - assert(t.value == 42); - } - assert(Type::count == 1); - Type::reset(); - // Check getting Type by value from a non-const rvalue any. - // This should cause the non-const copy constructor to be called. - { - Type t = any_cast<Type>(static_cast<any &&>(a)); - - assert(Type::count == 2); - assert(Type::copied == 1); - assert(Type::const_copied == 0); - assert(Type::non_const_copied == 1); - assert(Type::moved == 0); - assert(t.value == 42); - } - assert(Type::count == 1); - Type::reset(); - // Check getting const Type by value from a non-const rvalue any. - // This should cause the const copy constructor to be called. - { - Type t = any_cast<Type const>(static_cast<any &&>(a)); - - assert(Type::count == 2); - assert(Type::copied == 1); - assert(Type::const_copied == 1); - assert(Type::non_const_copied == 0); - assert(Type::moved == 0); - assert(t.value == 42); - } - assert(Type::count == 1); - Type::reset(); - // Check getting Type by value from a const rvalue any. - // This should cause the const copy constructor to be called. - { - Type t = any_cast<Type>(static_cast<any const&&>(a)); - - assert(Type::count == 2); - assert(Type::copied == 1); - assert(Type::const_copied == 1); - assert(Type::non_const_copied == 0); - assert(Type::moved == 0); - assert(t.value == 42); - } - // Ensure we still only have 1 Type object alive. - assert(Type::count == 1); - - // Check that the original object hasn't been changed. - assertContains<Type>(a, 42); - } - assert(Type::count == 0); -} - -// Even though you can't get a non-copyable class into std::any -// the standard requires that these overloads compile and function. -void test_non_copyable_ref() { - struct no_copy - { - no_copy() {} - no_copy(no_copy &&) {} - private: - no_copy(no_copy const &); - }; - - any a; - checkThrows<no_copy &, no_copy const&>(a); - checkThrows<no_copy const&>(a); - assertEmpty(a); -} - -int main() { - test_cast_is_not_noexcept(); - test_cast_return_type(); - test_cast_empty(); - test_cast_to_reference<small>(); - test_cast_to_reference<large>(); - test_cast_to_value<small>(); - test_cast_to_value<large>(); - test_non_copyable_ref(); -} diff --git a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/const_correctness.fail.cpp b/libcxx/test/std/experimental/any/any.nonmembers/any.cast/const_correctness.fail.cpp deleted file mode 100644 index db5149265cc..00000000000 --- a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/const_correctness.fail.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// template <class ValueType> -// ValueType any_cast(any const &); - -// Try and cast away const. - -#include <experimental/any> - -struct TestType {}; -struct TestType2 {}; - -int main() -{ - using std::experimental::any; - using std::experimental::any_cast; - - any a; - - // expected-error@experimental/any:* 2 {{binding value of type '_Tp' (aka 'const TestType') to reference to type 'TestType' drops 'const' qualifier}} - any_cast<TestType &>(static_cast<any const&>(a)); // expected-note {{requested here}} - any_cast<TestType &&>(static_cast<any const&>(a)); // expected-note {{requested here}} - - // expected-error@experimental/any:* 2 {{binding value of type '_Tp' (aka 'const TestType2') to reference to type 'TestType2' drops 'const' qualifier}} - any_cast<TestType2 &>(static_cast<any const&&>(a)); // expected-note {{requested here}} - any_cast<TestType2 &&>(static_cast<any const&&>(a)); // expected-note {{requested here}} -} diff --git a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp b/libcxx/test/std/experimental/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp deleted file mode 100644 index 1c52a64fce6..00000000000 --- a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp +++ /dev/null @@ -1,45 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// template <class ValueType> -// ValueType const any_cast(any const&); -// -// template <class ValueType> -// ValueType any_cast(any &); -// -// template <class ValueType> -// ValueType any_cast(any &&); - -// Test instantiating the any_cast with a non-copyable type. - -#include <experimental/any> - -using std::experimental::any; -using std::experimental::any_cast; - -struct no_copy -{ - no_copy() {} - no_copy(no_copy &&) {} -private: - no_copy(no_copy const &); -}; - -int main() { - any a; - any_cast<no_copy>(static_cast<any&>(a)); - any_cast<no_copy>(static_cast<any const&>(a)); - any_cast<no_copy>(static_cast<any &&>(a)); - // expected-error@experimental/any:* 3 {{static_assert failed "_ValueType is required to be a reference or a CopyConstructible type."}} - // expected-error@experimental/any:* 3 {{calling a private constructor of class 'no_copy'}} -} diff --git a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/reference_types.fail.cpp b/libcxx/test/std/experimental/any/any.nonmembers/any.cast/reference_types.fail.cpp deleted file mode 100644 index edef3d0a42b..00000000000 --- a/libcxx/test/std/experimental/any/any.nonmembers/any.cast/reference_types.fail.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// template <class ValueType> -// ValueType const* any_cast(any const *) noexcept; -// -// template <class ValueType> -// ValueType * any_cast(any *) noexcept; - -#include <experimental/any> - -using std::experimental::any; -using std::experimental::any_cast; - -int main() -{ - any a(1); - any_cast<int &>(&a); // expected-error-re@experimental/any:* 1 {{static_assert failed{{.*}} "_ValueType may not be a reference."}} - any_cast<int &&>(&a); // expected-error-re@experimental/any:* 1 {{static_assert failed{{.*}} "_ValueType may not be a reference."}} - any_cast<int const &>(&a); // expected-error-re@experimental/any:* 1 {{static_assert failed{{.*}} "_ValueType may not be a reference."}} - any_cast<int const&&>(&a); // expected-error-re@experimental/any:* 1 {{static_assert failed{{.*}} "_ValueType may not be a reference."}} - any const& a2 = a; - any_cast<int &>(&a2); // expected-error-re@experimental/any:* 1 {{static_assert failed{{.*}} "_ValueType may not be a reference."}} - any_cast<int &&>(&a2); // expected-error-re@experimental/any:* 1 {{static_assert failed{{.*}} "_ValueType may not be a reference."}} - any_cast<int const &>(&a2); // expected-error-re@experimental/any:* 1 {{static_assert failed{{.*}} "_ValueType may not be a reference."}} - any_cast<int const &&>(&a2); // expected-error-re@experimental/any:* 1 {{static_assert failed{{.*}} "_ValueType may not be a reference."}} -} diff --git a/libcxx/test/std/experimental/any/any.nonmembers/swap.pass.cpp b/libcxx/test/std/experimental/any/any.nonmembers/swap.pass.cpp deleted file mode 100644 index e79bc9ef099..00000000000 --- a/libcxx/test/std/experimental/any/any.nonmembers/swap.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// <experimental/any> - -// void swap(any &, any &) noexcept - -// swap(...) just wraps any::swap(...). That function is tested elsewhere. - -#include <experimental/any> -#include <cassert> - -using std::experimental::any; -using std::experimental::any_cast; - -int main() -{ - - { // test noexcept - any a; - static_assert(noexcept(swap(a, a)), "swap(any&, any&) must be noexcept"); - } - { - any a1(1); - any a2(2); - - swap(a1, a2); - - // Support testing against system dylibs that don't have bad_any_cast. - assert(*any_cast<int>(&a1) == 2); - assert(*any_cast<int>(&a2) == 1); - } -} |

