[libcxx] r194867 - Move <optional> into include/experimental, and into the std::experimental namespace, since it's not part of C++14, but of an upcoming TS
Marshall Clow
mclow.lists at gmail.com
Fri Nov 15 14:42:11 PST 2013
Author: marshall
Date: Fri Nov 15 16:42:10 2013
New Revision: 194867
URL: http://llvm.org/viewvc/llvm-project?rev=194867&view=rev
Log:
Move <optional> into include/experimental, and into the std::experimental namespace, since it's not part of C++14, but of an upcoming TS
Added:
libcxx/trunk/include/experimental/optional
- copied, changed from r194716, libcxx/trunk/include/optional
Removed:
libcxx/trunk/include/optional
Modified:
libcxx/trunk/src/optional.cpp
libcxx/trunk/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp
libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp
libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp
libcxx/trunk/test/utilities/optional/optional.bad_optional_access/default.pass.cpp
libcxx/trunk/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp
libcxx/trunk/test/utilities/optional/optional.bad_optional_access/string.pass.cpp
libcxx/trunk/test/utilities/optional/optional.comp_with_t/equal.pass.cpp
libcxx/trunk/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp
libcxx/trunk/test/utilities/optional/optional.hash/hash.pass.cpp
libcxx/trunk/test/utilities/optional/optional.inplace/in_place_t.pass.cpp
libcxx/trunk/test/utilities/optional/optional.nullops/eqaul.pass.cpp
libcxx/trunk/test/utilities/optional/optional.nullops/less_than.pass.cpp
libcxx/trunk/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional_const_void.fail.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp
libcxx/trunk/test/utilities/optional/optional.object/optional_void.fail.cpp
libcxx/trunk/test/utilities/optional/optional.object/types.pass.cpp
libcxx/trunk/test/utilities/optional/optional.relops/equal.pass.cpp
libcxx/trunk/test/utilities/optional/optional.relops/less_than.pass.cpp
libcxx/trunk/test/utilities/optional/optional.specalg/make_optional.pass.cpp
libcxx/trunk/test/utilities/optional/optional.specalg/swap.pass.cpp
libcxx/trunk/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp
libcxx/trunk/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp
libcxx/trunk/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp
libcxx/trunk/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp
libcxx/trunk/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp
libcxx/trunk/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp
libcxx/trunk/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp
libcxx/trunk/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp
libcxx/trunk/test/utilities/optional/version.pass.cpp
Copied: libcxx/trunk/include/experimental/optional (from r194716, libcxx/trunk/include/optional)
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/optional?p2=libcxx/trunk/include/experimental/optional&p1=libcxx/trunk/include/optional&r1=194716&r2=194867&rev=194867&view=diff
==============================================================================
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/experimental/optional Fri Nov 15 16:42:10 2013
@@ -18,8 +18,7 @@
#include <initializer_list>
-namespace std
-{
+namespace std { namespace experimental {
// optional for object types
template <class T>
@@ -110,7 +109,7 @@ template <class T> constexpr optional<ty
template <class T> struct hash;
template <class T> struct hash<optional<T>>;
-} // std
+}} // std::experimental
*/
@@ -118,8 +117,7 @@ template <class T> struct hash<optional<
#include <functional>
#include <stdexcept>
-namespace std // purposefully not using versioning namespace
-{
+namespace std { namespace experimental {
class _LIBCPP_EXCEPTION_ABI bad_optional_access
: public logic_error
@@ -142,7 +140,7 @@ public:
virtual ~bad_optional_access() _NOEXCEPT;
};
-} // std
+}} // std::experimental
#if _LIBCPP_STD_VER > 11
@@ -163,7 +161,7 @@ public:
#pragma GCC system_header
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
+namespace std { namespace experimental { inline namespace __library_fundamentals_v1 {
struct in_place_t {};
constexpr in_place_t in_place{};
@@ -677,10 +675,14 @@ make_optional(_Tp&& __v)
return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v));
}
+}}} // namespace std::experimental::__library_fundamentals_v1
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
template <class _Tp>
-struct _LIBCPP_TYPE_VIS_ONLY hash<optional<_Tp> >
+struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::optional<_Tp> >
{
- typedef optional<_Tp> argument_type;
+ typedef std::experimental::optional<_Tp> argument_type;
typedef size_t result_type;
_LIBCPP_INLINE_VISIBILITY
Removed: libcxx/trunk/include/optional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=194866&view=auto
==============================================================================
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/optional (removed)
@@ -1,697 +0,0 @@
-// -*- C++ -*-
-//===-------------------------- optional ----------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_OPTIONAL
-#define _LIBCPP_OPTIONAL
-
-/*
- optional synopsis
-
-// C++1y
-
-#include <initializer_list>
-
-namespace std
-{
-
-// optional for object types
-template <class T>
-class optional
-{
-public:
- typedef T value_type;
-
- // constructors
- constexpr optional() noexcept;
- constexpr optional(nullopt_t) noexcept;
- optional(const optional&);
- optional(optional&&) noexcept(is_nothrow_move_constructible<T>::value);
- constexpr optional(const T&);
- constexpr optional(T&&);
- template <class... Args> constexpr explicit optional(in_place_t, Args&&...);
- template <class U, class... Args>
- constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
-
- // destructor
- ~optional();
-
- // assignment
- optional& operator=(nullopt_t) noexcept;
- optional& operator=(const optional&);
- optional& operator=(optional&&)
- noexcept(is_nothrow_move_assignable<T>::value &&
- is_nothrow_move_constructible<T>::value);
- template <class U> optional& operator=(U&&);
- template <class... Args> void emplace(Args&&...);
- template <class U, class... Args> void emplace(initializer_list<U>, Args&&...);
-
- // swap
- void swap(optional&)
- noexcept(is_nothrow_move_constructible<T>::value &&
- noexcept(swap(declval<T&>(), declval<T&>())));
-
- // observers
- constexpr T const* operator->() const;
- T* operator->();
- constexpr T const& operator*() const;
- T& operator*();
- constexpr explicit operator bool() const noexcept;
- constexpr T const& value() const;
- T& value();
- template <class U> constexpr T value_or(U&&) const&;
- template <class U> T value_or(U&&) &&;
-};
-
-// In-place construction
-struct in_place_t{};
-constexpr in_place_t in_place{};
-
-// Disengaged state indicator
-struct nullopt_t{see below};
-constexpr nullopt_t nullopt(unspecified);
-
-// class bad_optional_access
-class bad_optional_access
- : public logic_error
-{
-public:
- explicit bad_optional_access(const string& what_arg);
- explicit bad_optional_access(const char* what_arg);
-};
-
-// Relational operators
-template <class T> constexpr bool operator==(const optional<T>&, const optional<T>&);
-template <class T> constexpr bool operator< (const optional<T>&, const optional<T>&);
-
-// Comparison with nullopt
-template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;
-template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept;
-template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept;
-template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept;
-
-// Comparison with T
-template <class T> constexpr bool operator==(const optional<T>&, const T&);
-template <class T> constexpr bool operator==(const T&, const optional<T>&);
-template <class T> constexpr bool operator<(const optional<T>&, const T&);
-template <class T> constexpr bool operator<(const T&, const optional<T>&);
-
-// Specialized algorithms
-template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below);
-template <class T> constexpr optional<typename decay<T>::type> make_optional(T&&);
-
-// hash support
-template <class T> struct hash;
-template <class T> struct hash<optional<T>>;
-
-} // std
-
-*/
-
-#include <__config>
-#include <functional>
-#include <stdexcept>
-
-namespace std // purposefully not using versioning namespace
-{
-
-class _LIBCPP_EXCEPTION_ABI bad_optional_access
- : public logic_error
-{
-public:
-#if _LIBCPP_STD_VER > 11
- _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const string& __arg)
- : logic_error(__arg) {}
- _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const char* __arg)
- : logic_error(__arg) {}
- _LIBCPP_INLINE_VISIBILITY bad_optional_access(const bad_optional_access&) noexcept = default;
- _LIBCPP_INLINE_VISIBILITY bad_optional_access& operator=(const bad_optional_access&) noexcept = default;
-#else
-private:
- bad_optional_access(const bad_optional_access&);
- bad_optional_access& operator=(const bad_optional_access&);
-public:
-#endif // _LIBCPP_STD_VER > 11
- // Get the key function ~bad_optional_access() into the dylib even if not compiling for C++1y
- virtual ~bad_optional_access() _NOEXCEPT;
-};
-
-} // std
-
-#if _LIBCPP_STD_VER > 11
-
-#include <initializer_list>
-#include <type_traits>
-#include <new>
-#include <__functional_base>
-
-#include <__undef_min_max>
-
-#ifdef _LIBCPP_DEBUG
-# include <__debug>
-#else
-# define _LIBCPP_ASSERT(x, m) ((void)0)
-#endif
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-struct in_place_t {};
-constexpr in_place_t in_place{};
-
-struct nullopt_t
-{
- explicit constexpr nullopt_t(int) noexcept {}
-};
-
-constexpr nullopt_t nullopt{0};
-
-template <class _Tp, bool = is_trivially_destructible<_Tp>::value>
-class __optional_storage
-{
-protected:
- typedef _Tp value_type;
- union
- {
- char __null_state_;
- value_type __val_;
- };
- bool __engaged_ = false;
-
- _LIBCPP_INLINE_VISIBILITY
- ~__optional_storage()
- {
- if (__engaged_)
- __val_.~value_type();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage() noexcept
- : __null_state_('\0') {}
-
- _LIBCPP_INLINE_VISIBILITY
- __optional_storage(const __optional_storage& __x)
- : __engaged_(__x.__engaged_)
- {
- if (__engaged_)
- ::new(_VSTD::addressof(__val_)) value_type(__x.__val_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __optional_storage(__optional_storage&& __x)
- noexcept(is_nothrow_move_constructible<value_type>::value)
- : __engaged_(__x.__engaged_)
- {
- if (__engaged_)
- ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage(const value_type& __v)
- : __val_(__v),
- __engaged_(true) {}
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage(value_type&& __v)
- : __val_(_VSTD::move(__v)),
- __engaged_(true) {}
-
- template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- explicit __optional_storage(in_place_t, _Args&&... __args)
- : __val_(_VSTD::forward<_Args>(__args)...),
- __engaged_(true) {}
-};
-
-template <class _Tp>
-class __optional_storage<_Tp, true>
-{
-protected:
- typedef _Tp value_type;
- union
- {
- char __null_state_;
- value_type __val_;
- };
- bool __engaged_ = false;
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage() noexcept
- : __null_state_('\0') {}
-
- _LIBCPP_INLINE_VISIBILITY
- __optional_storage(const __optional_storage& __x)
- : __engaged_(__x.__engaged_)
- {
- if (__engaged_)
- ::new(_VSTD::addressof(__val_)) value_type(__x.__val_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __optional_storage(__optional_storage&& __x)
- noexcept(is_nothrow_move_constructible<value_type>::value)
- : __engaged_(__x.__engaged_)
- {
- if (__engaged_)
- ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage(const value_type& __v)
- : __val_(__v),
- __engaged_(true) {}
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr __optional_storage(value_type&& __v)
- : __val_(_VSTD::move(__v)),
- __engaged_(true) {}
-
- template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- explicit __optional_storage(in_place_t, _Args&&... __args)
- : __val_(_VSTD::forward<_Args>(__args)...),
- __engaged_(true) {}
-};
-
-template <class _Tp>
-class optional
- : private __optional_storage<_Tp>
-{
- typedef __optional_storage<_Tp> __base;
-public:
- typedef _Tp value_type;
-
- static_assert(!is_reference<value_type>::value,
- "Instantiation of optional with a reference type is ill-formed.");
- static_assert(!is_same<typename remove_cv<value_type>::type, in_place_t>::value,
- "Instantiation of optional with a in_place_t type is ill-formed.");
- static_assert(!is_same<typename remove_cv<value_type>::type, nullopt_t>::value,
- "Instantiation of optional with a nullopt_t type is ill-formed.");
- static_assert(is_object<value_type>::value,
- "Instantiation of optional with a non-object type is undefined behavior.");
- static_assert(is_nothrow_destructible<value_type>::value,
- "Instantiation of optional with an object type that is not noexcept destructible is undefined behavior.");
-
- _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
- _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default;
- _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default;
- _LIBCPP_INLINE_VISIBILITY ~optional() = default;
- _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
- _LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v)
- : __base(__v) {}
- _LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v)
- : __base(_VSTD::move(__v)) {}
-
- template <class... _Args,
- class = typename enable_if
- <
- is_constructible<value_type, _Args...>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- explicit optional(in_place_t, _Args&&... __args)
- : __base(in_place, _VSTD::forward<_Args>(__args)...) {}
-
- template <class _Up, class... _Args,
- class = typename enable_if
- <
- is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
- : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {}
-
- _LIBCPP_INLINE_VISIBILITY
- optional& operator=(nullopt_t) noexcept
- {
- if (this->__engaged_)
- {
- this->__val_.~value_type();
- this->__engaged_ = false;
- }
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- optional&
- operator=(const optional& __opt)
- {
- if (this->__engaged_ == __opt.__engaged_)
- {
- if (this->__engaged_)
- this->__val_ = __opt.__val_;
- }
- else
- {
- if (this->__engaged_)
- this->__val_.~value_type();
- else
- ::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_);
- this->__engaged_ = __opt.__engaged_;
- }
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- optional&
- operator=(optional&& __opt)
- noexcept(is_nothrow_move_assignable<value_type>::value &&
- is_nothrow_move_constructible<value_type>::value)
- {
- if (this->__engaged_ == __opt.__engaged_)
- {
- if (this->__engaged_)
- this->__val_ = _VSTD::move(__opt.__val_);
- }
- else
- {
- if (this->__engaged_)
- this->__val_.~value_type();
- else
- ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_));
- this->__engaged_ = __opt.__engaged_;
- }
- return *this;
- }
-
- template <class _Up,
- class = typename enable_if
- <
- is_same<typename remove_reference<_Up>::type, value_type>::value &&
- is_constructible<value_type, _Up>::value &&
- is_assignable<value_type&, _Up>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- optional&
- operator=(_Up&& __v)
- {
- if (this->__engaged_)
- this->__val_ = _VSTD::forward<_Up>(__v);
- else
- {
- ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v));
- this->__engaged_ = true;
- }
- return *this;
- }
-
- template <class... _Args,
- class = typename enable_if
- <
- is_constructible<value_type, _Args...>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- void
- emplace(_Args&&... __args)
- {
- *this = nullopt;
- ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
- this->__engaged_ = true;
- }
-
- template <class _Up, class... _Args,
- class = typename enable_if
- <
- is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- void
- emplace(initializer_list<_Up> __il, _Args&&... __args)
- {
- *this = nullopt;
- ::new(_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...);
- this->__engaged_ = true;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void
- swap(optional& __opt)
- noexcept(is_nothrow_move_constructible<value_type>::value &&
- __is_nothrow_swappable<value_type>::value)
- {
- using _VSTD::swap;
- if (this->__engaged_ == __opt.__engaged_)
- {
- if (this->__engaged_)
- swap(this->__val_, __opt.__val_);
- }
- else
- {
- if (this->__engaged_)
- {
- ::new(_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_));
- this->__val_.~value_type();
- }
- else
- {
- ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_));
- __opt.__val_.~value_type();
- }
- swap(this->__engaged_, __opt.__engaged_);
- }
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- value_type const*
- operator->() const
- {
- _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
- return __operator_arrow(__has_operator_addressof<value_type>{});
- }
-
- _LIBCPP_INLINE_VISIBILITY
- value_type*
- operator->()
- {
- _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
- return _VSTD::addressof(this->__val_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- const value_type&
- operator*() const
- {
- _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
- return this->__val_;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- value_type&
- operator*()
- {
- _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
- return this->__val_;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr explicit operator bool() const noexcept {return this->__engaged_;}
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr value_type const& value() const
- {
- if (!this->__engaged_)
- throw bad_optional_access("optional<T>::value: not engaged");
- return this->__val_;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- value_type& value()
- {
- if (!this->__engaged_)
- throw bad_optional_access("optional<T>::value: not engaged");
- return this->__val_;
- }
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- constexpr value_type value_or(_Up&& __v) const&
- {
- static_assert(is_copy_constructible<value_type>::value,
- "optional<T>::value_or: T must be copy constructible");
- static_assert(is_convertible<_Up, value_type>::value,
- "optional<T>::value_or: U must be convertible to T");
- return this->__engaged_ ? this->__val_ :
- static_cast<value_type>(_VSTD::forward<_Up>(__v));
- }
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- value_type value_or(_Up&& __v) &&
- {
- static_assert(is_move_constructible<value_type>::value,
- "optional<T>::value_or: T must be move constructible");
- static_assert(is_convertible<_Up, value_type>::value,
- "optional<T>::value_or: U must be convertible to T");
- return this->__engaged_ ? _VSTD::move(this->__val_) :
- static_cast<value_type>(_VSTD::forward<_Up>(__v));
- }
-
-private:
- _LIBCPP_INLINE_VISIBILITY
- value_type const*
- __operator_arrow(true_type) const
- {
- return _VSTD::addressof(this->__val_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- value_type const*
- __operator_arrow(false_type) const
- {
- return &this->__val_;
- }
-};
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator==(const optional<_Tp>& __x, const optional<_Tp>& __y)
-{
- if (static_cast<bool>(__x) != static_cast<bool>(__y))
- return false;
- if (!static_cast<bool>(__x))
- return true;
- return *__x == *__y;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
-{
- if (!static_cast<bool>(__y))
- return false;
- if (!static_cast<bool>(__x))
- return true;
- return less<_Tp>{}(*__x, *__y);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator==(const optional<_Tp>& __x, nullopt_t) noexcept
-{
- return !static_cast<bool>(__x);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator==(nullopt_t, const optional<_Tp>& __x) noexcept
-{
- return !static_cast<bool>(__x);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator<(const optional<_Tp>&, nullopt_t) noexcept
-{
- return false;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator<(nullopt_t, const optional<_Tp>& __x) noexcept
-{
- return static_cast<bool>(__x);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator==(const optional<_Tp>& __x, const _Tp& __v)
-{
- return static_cast<bool>(__x) ? *__x == __v : false;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator==(const _Tp& __v, const optional<_Tp>& __x)
-{
- return static_cast<bool>(__x) ? *__x == __v : false;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator<(const optional<_Tp>& __x, const _Tp& __v)
-{
- return static_cast<bool>(__x) ? less<_Tp>{}(*__x, __v) : true;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-bool
-operator<(const _Tp& __v, const optional<_Tp>& __x)
-{
- return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y)))
-{
- __x.swap(__y);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr
-optional<typename decay<_Tp>::type>
-make_optional(_Tp&& __v)
-{
- return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v));
-}
-
-template <class _Tp>
-struct _LIBCPP_TYPE_VIS_ONLY hash<optional<_Tp> >
-{
- typedef optional<_Tp> argument_type;
- typedef size_t result_type;
-
- _LIBCPP_INLINE_VISIBILITY
- result_type operator()(const argument_type& __opt) const _NOEXCEPT
- {
- return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0;
- }
-};
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP_STD_VER > 11
-
-#endif // _LIBCPP_ARRAY
Modified: libcxx/trunk/src/optional.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/optional.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/src/optional.cpp (original)
+++ libcxx/trunk/src/optional.cpp Fri Nov 15 16:42:10 2013
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "optional"
+#include "experimental/optional"
namespace std // purposefully not using versioning namespace
-{
+{ namespace experimental {
#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
@@ -22,4 +22,4 @@ bad_optional_access::~bad_optional_acces
#endif
-} // std
+}} // std::experimental
Modified: libcxx/trunk/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,20 +12,18 @@
// class bad_optional_access;
// explicit bad_optional_access(const char* what_arg);
-#include <optional>
+#include <experimental/optional>
#include <string>
#include <cstring>
#include <cassert>
-#if _LIBCPP_STD_VER > 11
-
-#endif // _LIBCPP_STD_VER > 11
-
int main()
{
#if _LIBCPP_STD_VER > 11
+ using std::experimental::bad_optional_access;
+
const char* s = "message";
- std::bad_optional_access e(s);
+ bad_optional_access e(s);
assert(std::strcmp(e.what(), s) == 0);
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,24 +12,22 @@
// class bad_optional_access;
// bad_optional_access& operator=(const bad_optional_access&);
-#include <optional>
+#include <experimental/optional>
#include <string>
#include <cstring>
#include <type_traits>
#include <cassert>
-#if _LIBCPP_STD_VER > 11
-
-#endif // _LIBCPP_STD_VER > 11
-
int main()
{
#if _LIBCPP_STD_VER > 11
- static_assert(std::is_nothrow_copy_assignable<std::bad_optional_access>::value, "");
+ using std::experimental::bad_optional_access;
+
+ static_assert(std::is_nothrow_copy_assignable<bad_optional_access>::value, "");
const std::string s1("one message");
const std::string s2("another message");
- std::bad_optional_access e1(s1);
- std::bad_optional_access e2(s2);
+ bad_optional_access e1(s1);
+ bad_optional_access e2(s2);
assert(std::strcmp(e1.what(), e2.what()) != 0);
e1 = e2;
assert(std::strcmp(e1.what(), e2.what()) == 0);
Modified: libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,23 +12,21 @@
// class bad_optional_access;
// bad_optional_access(const bad_optional_access&);
-#include <optional>
+#include <experimental/optional>
#include <string>
#include <cstring>
#include <type_traits>
#include <cassert>
-#if _LIBCPP_STD_VER > 11
-
-#endif // _LIBCPP_STD_VER > 11
-
int main()
{
#if _LIBCPP_STD_VER > 11
- static_assert(std::is_nothrow_copy_constructible<std::bad_optional_access>::value, "");
+ using std::experimental::bad_optional_access;
+
+ static_assert(std::is_nothrow_copy_constructible<bad_optional_access>::value, "");
const std::string s("another message");
- std::bad_optional_access e1(s);
- std::bad_optional_access e2 = e1;
+ bad_optional_access e1(s);
+ bad_optional_access e2 = e1;
assert(std::strcmp(e1.what(), e2.what()) == 0);
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.bad_optional_access/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.bad_optional_access/default.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.bad_optional_access/default.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.bad_optional_access/default.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,16 +11,14 @@
// class bad_optional_access is not default constructible
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
-#if _LIBCPP_STD_VER > 11
-
-#endif // _LIBCPP_STD_VER > 11
-
int main()
{
#if _LIBCPP_STD_VER > 11
- static_assert(!std::is_default_constructible<std::bad_optional_access>::value, "");
+ using std::experimental::bad_optional_access;
+
+ static_assert(!std::is_default_constructible<bad_optional_access>::value, "");
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,17 +11,15 @@
// class bad_optional_access : public logic_error
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
-#if _LIBCPP_STD_VER > 11
-
-#endif // _LIBCPP_STD_VER > 11
-
int main()
{
#if _LIBCPP_STD_VER > 11
- static_assert(std::is_base_of<std::logic_error, std::bad_optional_access>::value, "");
- static_assert(std::is_convertible<std::bad_optional_access*, std::logic_error*>::value, "");
+ using std::experimental::bad_optional_access;
+
+ static_assert(std::is_base_of<std::logic_error, bad_optional_access>::value, "");
+ static_assert(std::is_convertible<bad_optional_access*, std::logic_error*>::value, "");
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.bad_optional_access/string.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.bad_optional_access/string.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.bad_optional_access/string.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.bad_optional_access/string.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,20 +12,18 @@
// class bad_optional_access;
// explicit bad_optional_access(const string& what_arg);
-#include <optional>
+#include <experimental/optional>
#include <string>
#include <cstring>
#include <cassert>
-#if _LIBCPP_STD_VER > 11
-
-#endif // _LIBCPP_STD_VER > 11
-
int main()
{
#if _LIBCPP_STD_VER > 11
+ using std::experimental::bad_optional_access;
+
const std::string s("message");
- std::bad_optional_access e(s);
+ bad_optional_access e(s);
assert(std::strcmp(e.what(), s.c_str()) == 0);
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.comp_with_t/equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.comp_with_t/equal.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.comp_with_t/equal.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.comp_with_t/equal.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,10 +12,12 @@
// template <class T> constexpr bool operator==(const optional<T>& x, const T& v);
// template <class T> constexpr bool operator==(const T& v, const optional<T>& x);
-#include <optional>
+#include <experimental/optional>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
int i_;
@@ -33,7 +35,7 @@ int main()
#if _LIBCPP_STD_VER > 11
{
typedef X T;
- typedef std::optional<T> O;
+ typedef optional<T> O;
constexpr T val(2);
constexpr O o1; // disengaged
Modified: libcxx/trunk/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,10 +12,12 @@
// template <class T> constexpr bool operator<(const optional<T>& x, const T& v);
// template <class T> constexpr bool operator<(const T& v, const optional<T>& x);
-#include <optional>
+#include <experimental/optional>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
int i_;
@@ -34,7 +36,7 @@ int main()
{
typedef X T;
- typedef std::optional<T> O;
+ typedef optional<T> O;
constexpr T val(2);
constexpr O o1; // disengaged
Modified: libcxx/trunk/test/utilities/optional/optional.hash/hash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.hash/hash.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.hash/hash.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.hash/hash.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,38 +11,37 @@
// template <class T> struct hash<optional<T>>;
-#include <optional>
+#include <experimental/optional>
#include <string>
#include <memory>
#include <cassert>
-#if _LIBCPP_STD_VER > 11
-
-#endif // _LIBCPP_STD_VER > 11
int main()
{
#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
{
typedef int T;
- std::optional<T> opt;
- assert(std::hash<std::optional<T>>{}(opt) == 0);
+ optional<T> opt;
+ assert(std::hash<optional<T>>{}(opt) == 0);
opt = 2;
- assert(std::hash<std::optional<T>>{}(opt) == std::hash<T>{}(*opt));
+ assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt));
}
{
typedef std::string T;
- std::optional<T> opt;
- assert(std::hash<std::optional<T>>{}(opt) == 0);
+ optional<T> opt;
+ assert(std::hash<optional<T>>{}(opt) == 0);
opt = std::string("123");
- assert(std::hash<std::optional<T>>{}(opt) == std::hash<T>{}(*opt));
+ assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt));
}
{
typedef std::unique_ptr<int> T;
- std::optional<T> opt;
- assert(std::hash<std::optional<T>>{}(opt) == 0);
+ optional<T> opt;
+ assert(std::hash<optional<T>>{}(opt) == 0);
opt = std::unique_ptr<int>(new int(3));
- assert(std::hash<std::optional<T>>{}(opt) == std::hash<T>{}(*opt));
+ assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt));
}
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.inplace/in_place_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.inplace/in_place_t.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.inplace/in_place_t.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.inplace/in_place_t.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,14 +12,18 @@
// struct in_place_t{};
// constexpr in_place_t in_place{};
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
constexpr
int
-test(const std::in_place_t&)
+test(const in_place_t&)
{
return 3;
}
@@ -30,9 +34,9 @@ int main()
{
#if _LIBCPP_STD_VER > 11
- static_assert((std::is_class<std::in_place_t>::value), "");
- static_assert((std::is_empty<std::in_place_t>::value), "");
+ static_assert((std::is_class<in_place_t>::value), "");
+ static_assert((std::is_empty<in_place_t>::value), "");
- static_assert(test(std::in_place) == 3, "");
+ static_assert(test(in_place) == 3, "");
#endif
}
Modified: libcxx/trunk/test/utilities/optional/optional.nullops/eqaul.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.nullops/eqaul.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.nullops/eqaul.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.nullops/eqaul.pass.cpp Fri Nov 15 16:42:10 2013
@@ -13,25 +13,29 @@
// template <class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept;
// template <class T> constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept;
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
{
typedef int T;
- typedef std::optional<T> O;
+ typedef optional<T> O;
constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
- static_assert ( std::nullopt == o1 , "" );
- static_assert ( !(std::nullopt == o2), "" );
- static_assert ( o1 == std::nullopt , "" );
- static_assert ( !(o2 == std::nullopt), "" );
+ static_assert ( nullopt == o1 , "" );
+ static_assert ( !(nullopt == o2), "" );
+ static_assert ( o1 == nullopt , "" );
+ static_assert ( !(o2 == nullopt), "" );
- static_assert (noexcept(std::nullopt == o1), "");
- static_assert (noexcept(o1 == std::nullopt), "");
+ static_assert (noexcept(nullopt == o1), "");
+ static_assert (noexcept(o1 == nullopt), "");
}
#endif
}
Modified: libcxx/trunk/test/utilities/optional/optional.nullops/less_than.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.nullops/less_than.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.nullops/less_than.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.nullops/less_than.pass.cpp Fri Nov 15 16:42:10 2013
@@ -13,25 +13,29 @@
// template <class T> constexpr bool operator<(const optional<T>& x, nullopt_t) noexcept;
// template <class T> constexpr bool operator<(nullopt_t, const optional<T>& x) noexcept;
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
{
typedef int T;
- typedef std::optional<T> O;
+ typedef optional<T> O;
constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
- static_assert ( !(std::nullopt < o1), "" );
- static_assert ( std::nullopt < o2 , "" );
- static_assert ( !(o1 < std::nullopt), "" );
- static_assert ( !(o2 < std::nullopt), "" );
+ static_assert ( !(nullopt < o1), "" );
+ static_assert ( nullopt < o2 , "" );
+ static_assert ( !(o1 < nullopt), "" );
+ static_assert ( !(o2 < nullopt), "" );
- static_assert (noexcept(std::nullopt < o1), "");
- static_assert (noexcept(o1 < std::nullopt), "");
+ static_assert (noexcept(nullopt < o1), "");
+ static_assert (noexcept(o1 < nullopt), "");
}
#endif
}
Modified: libcxx/trunk/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,14 +12,18 @@
// struct nullopt_t{see below};
// constexpr nullopt_t nullopt(unspecified);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+using std::experimental::nullopt_t;
+using std::experimental::nullopt;
+
constexpr
int
-test(const std::nullopt_t&)
+test(const nullopt_t&)
{
return 3;
}
@@ -29,11 +33,11 @@ test(const std::nullopt_t&)
int main()
{
#if _LIBCPP_STD_VER > 11
- static_assert((std::is_class<std::nullopt_t>::value), "");
- static_assert((std::is_empty<std::nullopt_t>::value), "");
- static_assert((std::is_literal_type<std::nullopt_t>::value), "");
- static_assert((!std::is_default_constructible<std::nullopt_t>::value), "");
+ static_assert((std::is_class<nullopt_t>::value), "");
+ static_assert((std::is_empty<nullopt_t>::value), "");
+ static_assert((std::is_literal_type<nullopt_t>::value), "");
+ static_assert((!std::is_default_constructible<nullopt_t>::value), "");
- static_assert(test(std::nullopt) == 3, "");
+ static_assert(test(nullopt) == 3, "");
#endif
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,13 +11,15 @@
// template <class U> optional<T>& operator=(U&& v);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#include <memory>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
};
@@ -27,41 +29,41 @@ struct X
int main()
{
#if _LIBCPP_STD_VER > 11
- static_assert(std::is_assignable<std::optional<int>, int>::value, "");
- static_assert(std::is_assignable<std::optional<int>, int&>::value, "");
- static_assert(std::is_assignable<std::optional<int>&, int>::value, "");
- static_assert(std::is_assignable<std::optional<int>&, int&>::value, "");
- static_assert(std::is_assignable<std::optional<int>&, const int&>::value, "");
- static_assert(!std::is_assignable<const std::optional<int>&, const int&>::value, "");
- static_assert(!std::is_assignable<std::optional<int>, X>::value, "");
+ static_assert(std::is_assignable<optional<int>, int>::value, "");
+ static_assert(std::is_assignable<optional<int>, int&>::value, "");
+ static_assert(std::is_assignable<optional<int>&, int>::value, "");
+ static_assert(std::is_assignable<optional<int>&, int&>::value, "");
+ static_assert(std::is_assignable<optional<int>&, const int&>::value, "");
+ static_assert(!std::is_assignable<const optional<int>&, const int&>::value, "");
+ static_assert(!std::is_assignable<optional<int>, X>::value, "");
{
- std::optional<int> opt;
+ optional<int> opt;
opt = 1;
assert(static_cast<bool>(opt) == true);
assert(*opt == 1);
}
{
- std::optional<int> opt;
+ optional<int> opt;
const int i = 2;
opt = i;
assert(static_cast<bool>(opt) == true);
assert(*opt == i);
}
{
- std::optional<int> opt(3);
+ optional<int> opt(3);
const int i = 2;
opt = i;
assert(static_cast<bool>(opt) == true);
assert(*opt == i);
}
{
- std::optional<std::unique_ptr<int>> opt;
+ optional<std::unique_ptr<int>> opt;
opt = std::unique_ptr<int>(new int(3));
assert(static_cast<bool>(opt) == true);
assert(**opt == 3);
}
{
- std::optional<std::unique_ptr<int>> opt(std::unique_ptr<int>(new int(2)));
+ optional<std::unique_ptr<int>> opt(std::unique_ptr<int>(new int(2)));
opt = std::unique_ptr<int>(new int(3));
assert(static_cast<bool>(opt) == true);
assert(**opt == 3);
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// optional<T>& operator=(const optional<T>& rhs);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
static bool throw_now;
@@ -37,15 +39,15 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- std::optional<int> opt;
- constexpr std::optional<int> opt2;
+ optional<int> opt;
+ constexpr optional<int> opt2;
opt = opt2;
static_assert(static_cast<bool>(opt2) == false, "");
assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
}
{
- std::optional<int> opt;
- constexpr std::optional<int> opt2(2);
+ optional<int> opt;
+ constexpr optional<int> opt2(2);
opt = opt2;
static_assert(static_cast<bool>(opt2) == true, "");
static_assert(*opt2 == 2, "");
@@ -53,15 +55,15 @@ int main()
assert(*opt == *opt2);
}
{
- std::optional<int> opt(3);
- constexpr std::optional<int> opt2;
+ optional<int> opt(3);
+ constexpr optional<int> opt2;
opt = opt2;
static_assert(static_cast<bool>(opt2) == false, "");
assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
}
{
- std::optional<int> opt(3);
- constexpr std::optional<int> opt2(2);
+ optional<int> opt(3);
+ constexpr optional<int> opt2(2);
opt = opt2;
static_assert(static_cast<bool>(opt2) == true, "");
static_assert(*opt2 == 2, "");
@@ -69,8 +71,8 @@ int main()
assert(*opt == *opt2);
}
{
- std::optional<X> opt;
- std::optional<X> opt2(X{});
+ optional<X> opt;
+ optional<X> opt2(X{});
assert(static_cast<bool>(opt2) == true);
try
{
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,13 +11,15 @@
// template <class... Args> void optional<T>::emplace(Args&&... args);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#include <memory>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
class X
{
int i_;
@@ -58,61 +60,61 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- std::optional<int> opt;
+ optional<int> opt;
opt.emplace();
assert(static_cast<bool>(opt) == true);
assert(*opt == 0);
}
{
- std::optional<int> opt;
+ optional<int> opt;
opt.emplace(1);
assert(static_cast<bool>(opt) == true);
assert(*opt == 1);
}
{
- std::optional<int> opt(2);
+ optional<int> opt(2);
opt.emplace();
assert(static_cast<bool>(opt) == true);
assert(*opt == 0);
}
{
- std::optional<int> opt(2);
+ optional<int> opt(2);
opt.emplace(1);
assert(static_cast<bool>(opt) == true);
assert(*opt == 1);
}
{
- std::optional<X> opt;
+ optional<X> opt;
opt.emplace();
assert(static_cast<bool>(opt) == true);
assert(*opt == X());
}
{
- std::optional<X> opt;
+ optional<X> opt;
opt.emplace(1);
assert(static_cast<bool>(opt) == true);
assert(*opt == X(1));
}
{
- std::optional<X> opt;
+ optional<X> opt;
opt.emplace(1, 2);
assert(static_cast<bool>(opt) == true);
assert(*opt == X(1, 2));
}
{
- std::optional<X> opt(X{3});
+ optional<X> opt(X{3});
opt.emplace();
assert(static_cast<bool>(opt) == true);
assert(*opt == X());
}
{
- std::optional<X> opt(X{3});
+ optional<X> opt(X{3});
opt.emplace(1);
assert(static_cast<bool>(opt) == true);
assert(*opt == X(1));
}
{
- std::optional<X> opt(X{3});
+ optional<X> opt(X{3});
opt.emplace(1, 2);
assert(static_cast<bool>(opt) == true);
assert(*opt == X(1, 2));
@@ -120,7 +122,7 @@ int main()
{
Y y;
{
- std::optional<Y> opt(y);
+ optional<Y> opt(y);
assert(Y::dtor_called == false);
opt.emplace();
assert(Y::dtor_called == true);
@@ -128,7 +130,7 @@ int main()
}
{
Z z;
- std::optional<Z> opt(z);
+ optional<Z> opt(z);
try
{
assert(static_cast<bool>(opt) == true);
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,13 +12,15 @@
// template <class U, class... Args>
// void optional<T>::emplace(initializer_list<U> il, Args&&... args);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#include <vector>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
class X
{
int i_;
@@ -75,7 +77,7 @@ int main()
{
X x;
{
- std::optional<X> opt(x);
+ optional<X> opt(x);
assert(X::dtor_called == false);
opt.emplace({1, 2});
assert(X::dtor_called == true);
@@ -83,20 +85,20 @@ int main()
}
}
{
- std::optional<std::vector<int>> opt;
+ optional<std::vector<int>> opt;
opt.emplace({1, 2, 3}, std::allocator<int>());
assert(static_cast<bool>(opt) == true);
assert(*opt == std::vector<int>({1, 2, 3}));
}
{
- std::optional<Y> opt;
+ optional<Y> opt;
opt.emplace({1, 2});
assert(static_cast<bool>(opt) == true);
assert(*opt == Y({1, 2}));
}
{
Z z;
- std::optional<Z> opt(z);
+ optional<Z> opt(z);
try
{
assert(static_cast<bool>(opt) == true);
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp Fri Nov 15 16:42:10 2013
@@ -13,12 +13,14 @@
// noexcept(is_nothrow_move_assignable<T>::value &&
// is_nothrow_move_constructible<T>::value);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
static bool throw_now;
@@ -45,16 +47,16 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- static_assert(std::is_nothrow_move_assignable<std::optional<int>>::value, "");
- std::optional<int> opt;
- constexpr std::optional<int> opt2;
+ static_assert(std::is_nothrow_move_assignable<optional<int>>::value, "");
+ optional<int> opt;
+ constexpr optional<int> opt2;
opt = std::move(opt2);
static_assert(static_cast<bool>(opt2) == false, "");
assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
}
{
- std::optional<int> opt;
- constexpr std::optional<int> opt2(2);
+ optional<int> opt;
+ constexpr optional<int> opt2(2);
opt = std::move(opt2);
static_assert(static_cast<bool>(opt2) == true, "");
static_assert(*opt2 == 2, "");
@@ -62,15 +64,15 @@ int main()
assert(*opt == *opt2);
}
{
- std::optional<int> opt(3);
- constexpr std::optional<int> opt2;
+ optional<int> opt(3);
+ constexpr optional<int> opt2;
opt = std::move(opt2);
static_assert(static_cast<bool>(opt2) == false, "");
assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
}
{
- std::optional<int> opt(3);
- constexpr std::optional<int> opt2(2);
+ optional<int> opt(3);
+ constexpr optional<int> opt2(2);
opt = std::move(opt2);
static_assert(static_cast<bool>(opt2) == true, "");
static_assert(*opt2 == 2, "");
@@ -78,9 +80,9 @@ int main()
assert(*opt == *opt2);
}
{
- static_assert(!std::is_nothrow_move_assignable<std::optional<X>>::value, "");
- std::optional<X> opt;
- std::optional<X> opt2(X{});
+ static_assert(!std::is_nothrow_move_assignable<optional<X>>::value, "");
+ optional<X> opt;
+ optional<X> opt2(X{});
assert(static_cast<bool>(opt2) == true);
try
{
@@ -95,7 +97,7 @@ int main()
}
}
{
- static_assert(std::is_nothrow_move_assignable<std::optional<Y>>::value, "");
+ static_assert(std::is_nothrow_move_assignable<optional<Y>>::value, "");
}
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,16 @@
// optional<T>& operator=(nullopt_t) noexcept;
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+using std::experimental::nullopt_t;
+using std::experimental::nullopt;
+
struct X
{
static bool dtor_called;
@@ -31,30 +35,30 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- std::optional<int> opt;
- static_assert(noexcept(opt = std::nullopt) == true, "");
- opt = std::nullopt;
+ optional<int> opt;
+ static_assert(noexcept(opt = nullopt) == true, "");
+ opt = nullopt;
assert(static_cast<bool>(opt) == false);
}
{
- std::optional<int> opt(3);
- opt = std::nullopt;
+ optional<int> opt(3);
+ opt = nullopt;
assert(static_cast<bool>(opt) == false);
}
{
- std::optional<X> opt;
- static_assert(noexcept(opt = std::nullopt) == true, "");
+ optional<X> opt;
+ static_assert(noexcept(opt = nullopt) == true, "");
assert(X::dtor_called == false);
- opt = std::nullopt;
+ opt = nullopt;
assert(X::dtor_called == false);
assert(static_cast<bool>(opt) == false);
}
{
X x;
{
- std::optional<X> opt(x);
+ optional<X> opt(x);
assert(X::dtor_called == false);
- opt = std::nullopt;
+ opt = nullopt;
assert(X::dtor_called == true);
assert(static_cast<bool>(opt) == false);
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// constexpr optional(const T& v);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
class X
{
int i_;
@@ -52,12 +54,12 @@ int main()
{
typedef int T;
constexpr T t(5);
- constexpr std::optional<T> opt(t);
+ constexpr optional<T> opt(t);
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == 5, "");
struct test_constexpr_ctor
- : public std::optional<T>
+ : public optional<T>
{
constexpr test_constexpr_ctor(const T&) {}
};
@@ -66,12 +68,12 @@ int main()
{
typedef double T;
constexpr T t(3);
- constexpr std::optional<T> opt(t);
+ constexpr optional<T> opt(t);
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == 3, "");
struct test_constexpr_ctor
- : public std::optional<T>
+ : public optional<T>
{
constexpr test_constexpr_ctor(const T&) {}
};
@@ -80,19 +82,19 @@ int main()
{
typedef X T;
const T t(3);
- std::optional<T> opt(t);
+ optional<T> opt(t);
assert(static_cast<bool>(opt) == true);
assert(*opt == 3);
}
{
typedef Y T;
constexpr T t(3);
- constexpr std::optional<T> opt(t);
+ constexpr optional<T> opt(t);
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == 3, "");
struct test_constexpr_ctor
- : public std::optional<T>
+ : public optional<T>
{
constexpr test_constexpr_ctor(const T&) {}
};
@@ -103,7 +105,7 @@ int main()
try
{
const T t(3);
- std::optional<T> opt(t);
+ optional<T> opt(t);
assert(false);
}
catch (int i)
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,20 +11,22 @@
// optional(const optional<T>& rhs);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
template <class T>
void
-test(const std::optional<T>& rhs, bool is_going_to_throw = false)
+test(const optional<T>& rhs, bool is_going_to_throw = false)
{
bool rhs_engaged = static_cast<bool>(rhs);
try
{
- std::optional<T> lhs = rhs;
+ optional<T> lhs = rhs;
assert(is_going_to_throw == false);
assert(static_cast<bool>(lhs) == rhs_engaged);
if (rhs_engaged)
@@ -80,42 +82,42 @@ int main()
#if _LIBCPP_STD_VER > 11
{
typedef int T;
- std::optional<T> rhs;
+ optional<T> rhs;
test(rhs);
}
{
typedef int T;
- std::optional<T> rhs(3);
+ optional<T> rhs(3);
test(rhs);
}
{
typedef X T;
- std::optional<T> rhs;
+ optional<T> rhs;
test(rhs);
}
{
typedef X T;
- std::optional<T> rhs(X(3));
+ optional<T> rhs(X(3));
test(rhs);
}
{
typedef Y T;
- std::optional<T> rhs;
+ optional<T> rhs;
test(rhs);
}
{
typedef Y T;
- std::optional<T> rhs(Y(3));
+ optional<T> rhs(Y(3));
test(rhs);
}
{
typedef Z T;
- std::optional<T> rhs;
+ optional<T> rhs;
test(rhs);
}
{
typedef Z T;
- std::optional<T> rhs(Z(3));
+ optional<T> rhs(Z(3));
test(rhs, true);
}
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// constexpr optional() noexcept;
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
template <class Opt>
void
test_constexpr()
@@ -58,8 +60,8 @@ struct X
int main()
{
#if _LIBCPP_STD_VER > 11
- test_constexpr<std::optional<int>>();
- test_constexpr<std::optional<int*>>();
- test<std::optional<X>>();
+ test_constexpr<optional<int>>();
+ test_constexpr<optional<int*>>();
+ test<optional<X>>();
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,12 +12,16 @@
// template <class... Args>
// constexpr explicit optional(in_place_t, Args&&... args);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
class X
{
int i_;
@@ -60,76 +64,76 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- constexpr std::optional<int> opt(std::in_place, 5);
+ constexpr optional<int> opt(in_place, 5);
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == 5, "");
struct test_constexpr_ctor
- : public std::optional<int>
+ : public optional<int>
{
- constexpr test_constexpr_ctor(std::in_place_t, int i)
- : std::optional<int>(std::in_place, i) {}
+ constexpr test_constexpr_ctor(in_place_t, int i)
+ : optional<int>(in_place, i) {}
};
}
{
- const std::optional<X> opt(std::in_place);
+ const optional<X> opt(in_place);
assert(static_cast<bool>(opt) == true);
assert(*opt == X());
}
{
- const std::optional<X> opt(std::in_place, 5);
+ const optional<X> opt(in_place, 5);
assert(static_cast<bool>(opt) == true);
assert(*opt == X(5));
}
{
- const std::optional<X> opt(std::in_place, 5, 4);
+ const optional<X> opt(in_place, 5, 4);
assert(static_cast<bool>(opt) == true);
assert(*opt == X(5, 4));
}
{
- constexpr std::optional<Y> opt(std::in_place);
+ constexpr optional<Y> opt(in_place);
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == Y(), "");
struct test_constexpr_ctor
- : public std::optional<Y>
+ : public optional<Y>
{
- constexpr test_constexpr_ctor(std::in_place_t)
- : std::optional<Y>(std::in_place) {}
+ constexpr test_constexpr_ctor(in_place_t)
+ : optional<Y>(in_place) {}
};
}
{
- constexpr std::optional<Y> opt(std::in_place, 5);
+ constexpr optional<Y> opt(in_place, 5);
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == Y(5), "");
struct test_constexpr_ctor
- : public std::optional<Y>
+ : public optional<Y>
{
- constexpr test_constexpr_ctor(std::in_place_t, int i)
- : std::optional<Y>(std::in_place, i) {}
+ constexpr test_constexpr_ctor(in_place_t, int i)
+ : optional<Y>(in_place, i) {}
};
}
{
- constexpr std::optional<Y> opt(std::in_place, 5, 4);
+ constexpr optional<Y> opt(in_place, 5, 4);
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == Y(5, 4), "");
struct test_constexpr_ctor
- : public std::optional<Y>
+ : public optional<Y>
{
- constexpr test_constexpr_ctor(std::in_place_t, int i, int j)
- : std::optional<Y>(std::in_place, i, j) {}
+ constexpr test_constexpr_ctor(in_place_t, int i, int j)
+ : optional<Y>(in_place, i, j) {}
};
}
{
try
{
- const std::optional<Z> opt(std::in_place, 1);
+ const optional<Z> opt(in_place, 1);
assert(false);
}
catch (int i)
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp Fri Nov 15 16:42:10 2013
@@ -13,13 +13,17 @@
// constexpr
// explicit optional(in_place_t, initializer_list<U> il, Args&&... args);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <vector>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
class X
{
int i_;
@@ -70,39 +74,39 @@ int main()
#if _LIBCPP_STD_VER > 11
{
static_assert(!std::is_constructible<X, std::initializer_list<int>&>::value, "");
- static_assert(!std::is_constructible<std::optional<X>, std::initializer_list<int>&>::value, "");
+ static_assert(!std::is_constructible<optional<X>, std::initializer_list<int>&>::value, "");
}
{
- std::optional<std::vector<int>> opt(std::in_place, {3, 1});
+ optional<std::vector<int>> opt(in_place, {3, 1});
assert(static_cast<bool>(opt) == true);
assert((*opt == std::vector<int>{3, 1}));
assert(opt->size() == 2);
}
{
- std::optional<std::vector<int>> opt(std::in_place, {3, 1}, std::allocator<int>());
+ optional<std::vector<int>> opt(in_place, {3, 1}, std::allocator<int>());
assert(static_cast<bool>(opt) == true);
assert((*opt == std::vector<int>{3, 1}));
assert(opt->size() == 2);
}
{
- static_assert(std::is_constructible<std::optional<Y>, std::initializer_list<int>&>::value, "");
- constexpr std::optional<Y> opt(std::in_place, {3, 1});
+ static_assert(std::is_constructible<optional<Y>, std::initializer_list<int>&>::value, "");
+ constexpr optional<Y> opt(in_place, {3, 1});
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == Y{3, 1}, "");
struct test_constexpr_ctor
- : public std::optional<Y>
+ : public optional<Y>
{
- constexpr test_constexpr_ctor(std::in_place_t, std::initializer_list<int> i)
- : std::optional<Y>(std::in_place, i) {}
+ constexpr test_constexpr_ctor(in_place_t, std::initializer_list<int> i)
+ : optional<Y>(in_place, i) {}
};
}
{
- static_assert(std::is_constructible<std::optional<Z>, std::initializer_list<int>&>::value, "");
+ static_assert(std::is_constructible<optional<Z>, std::initializer_list<int>&>::value, "");
try
{
- std::optional<Z> opt(std::in_place, {3, 1});
+ optional<Z> opt(in_place, {3, 1});
assert(false);
}
catch (int i)
@@ -111,10 +115,10 @@ int main()
}
struct test_constexpr_ctor
- : public std::optional<Z>
+ : public optional<Z>
{
- constexpr test_constexpr_ctor(std::in_place_t, std::initializer_list<int> i)
- : std::optional<Z>(std::in_place, i) {}
+ constexpr test_constexpr_ctor(in_place_t, std::initializer_list<int> i)
+ : optional<Z>(in_place, i) {}
};
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,22 +11,24 @@
// optional(optional<T>&& rhs) noexcept(is_nothrow_move_constructible<T>::value);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
template <class T>
void
-test(std::optional<T>& rhs, bool is_going_to_throw = false)
+test(optional<T>& rhs, bool is_going_to_throw = false)
{
- static_assert(std::is_nothrow_move_constructible<std::optional<T>>::value ==
+ static_assert(std::is_nothrow_move_constructible<optional<T>>::value ==
std::is_nothrow_move_constructible<T>::value, "");
bool rhs_engaged = static_cast<bool>(rhs);
try
{
- std::optional<T> lhs = std::move(rhs);
+ optional<T> lhs = std::move(rhs);
assert(is_going_to_throw == false);
assert(static_cast<bool>(lhs) == rhs_engaged);
}
@@ -80,42 +82,42 @@ int main()
#if _LIBCPP_STD_VER > 11
{
typedef int T;
- std::optional<T> rhs;
+ optional<T> rhs;
test(rhs);
}
{
typedef int T;
- std::optional<T> rhs(3);
+ optional<T> rhs(3);
test(rhs);
}
{
typedef X T;
- std::optional<T> rhs;
+ optional<T> rhs;
test(rhs);
}
{
typedef X T;
- std::optional<T> rhs(X(3));
+ optional<T> rhs(X(3));
test(rhs);
}
{
typedef Y T;
- std::optional<T> rhs;
+ optional<T> rhs;
test(rhs);
}
{
typedef Y T;
- std::optional<T> rhs(Y(3));
+ optional<T> rhs(Y(3));
test(rhs);
}
{
typedef Z T;
- std::optional<T> rhs;
+ optional<T> rhs;
test(rhs);
}
{
typedef Z T;
- std::optional<T> rhs(Z(3));
+ optional<T> rhs(Z(3));
test(rhs, true);
}
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,18 +11,22 @@
// constexpr optional(nullopt_t) noexcept;
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+using std::experimental::nullopt_t;
+using std::experimental::nullopt;
+
template <class Opt>
void
test_constexpr()
{
- static_assert(noexcept(Opt(std::nullopt)), "");
- constexpr Opt opt(std::nullopt);
+ static_assert(noexcept(Opt(nullopt)), "");
+ constexpr Opt opt(nullopt);
static_assert(static_cast<bool>(opt) == false, "");
struct test_constexpr_ctor
@@ -36,8 +40,8 @@ template <class Opt>
void
test()
{
- static_assert(noexcept(Opt(std::nullopt)), "");
- Opt opt(std::nullopt);
+ static_assert(noexcept(Opt(nullopt)), "");
+ Opt opt(nullopt);
assert(static_cast<bool>(opt) == false);
struct test_constexpr_ctor
@@ -57,8 +61,8 @@ struct X
int main()
{
#if _LIBCPP_STD_VER > 11
- test_constexpr<std::optional<int>>();
- test_constexpr<std::optional<int*>>();
- test<std::optional<X>>();
+ test_constexpr<optional<int>>();
+ test_constexpr<optional<int*>>();
+ test<optional<X>>();
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// constexpr optional(T&& v);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
class X
{
int i_;
@@ -52,42 +54,42 @@ int main()
#if _LIBCPP_STD_VER > 11
{
typedef int T;
- constexpr std::optional<T> opt(T(5));
+ constexpr optional<T> opt(T(5));
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == 5, "");
struct test_constexpr_ctor
- : public std::optional<T>
+ : public optional<T>
{
constexpr test_constexpr_ctor(T&&) {}
};
}
{
typedef double T;
- constexpr std::optional<T> opt(T(3));
+ constexpr optional<T> opt(T(3));
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == 3, "");
struct test_constexpr_ctor
- : public std::optional<T>
+ : public optional<T>
{
constexpr test_constexpr_ctor(T&&) {}
};
}
{
typedef X T;
- std::optional<T> opt(T(3));
+ optional<T> opt(T(3));
assert(static_cast<bool>(opt) == true);
assert(*opt == 3);
}
{
typedef Y T;
- constexpr std::optional<T> opt(T(3));
+ constexpr optional<T> opt(T(3));
static_assert(static_cast<bool>(opt) == true, "");
static_assert(*opt == 3, "");
struct test_constexpr_ctor
- : public std::optional<T>
+ : public optional<T>
{
constexpr test_constexpr_ctor(T&&) {}
};
@@ -96,7 +98,7 @@ int main()
typedef Z T;
try
{
- std::optional<T> opt(T(3));
+ optional<T> opt(T(3));
assert(false);
}
catch (int i)
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// ~optional();
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
class X
{
public:
@@ -35,20 +37,20 @@ int main()
{
typedef int T;
static_assert(std::is_trivially_destructible<T>::value, "");
- static_assert(std::is_trivially_destructible<std::optional<T>>::value, "");
+ static_assert(std::is_trivially_destructible<optional<T>>::value, "");
}
{
typedef double T;
static_assert(std::is_trivially_destructible<T>::value, "");
- static_assert(std::is_trivially_destructible<std::optional<T>>::value, "");
+ static_assert(std::is_trivially_destructible<optional<T>>::value, "");
}
{
typedef X T;
static_assert(!std::is_trivially_destructible<T>::value, "");
- static_assert(!std::is_trivially_destructible<std::optional<T>>::value, "");
+ static_assert(!std::is_trivially_destructible<optional<T>>::value, "");
{
X x;
- std::optional<X> opt{x};
+ optional<X> opt{x};
assert(X::dtor_called == false);
}
assert(X::dtor_called == true);
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,19 +11,21 @@
// constexpr explicit optional<T>::operator bool() const noexcept;
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
{
- constexpr std::optional<int> opt;
+ constexpr optional<int> opt;
static_assert(!opt, "");
}
{
- constexpr std::optional<int> opt(0);
+ constexpr optional<int> opt(0);
static_assert(opt, "");
}
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp Fri Nov 15 16:42:10 2013
@@ -15,12 +15,14 @@
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
constexpr int test() const {return 3;}
@@ -33,12 +35,12 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- std::optional<X> opt(X{});
+ optional<X> opt(X{});
assert((*opt).test() == 4);
}
#ifdef _LIBCPP_DEBUG
{
- std::optional<X> opt;
+ optional<X> opt;
assert((*opt).test() == 3);
assert(false);
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp Fri Nov 15 16:42:10 2013
@@ -15,12 +15,14 @@
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
constexpr int test() const {return 3;}
@@ -37,16 +39,16 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- constexpr std::optional<X> opt(X{});
+ constexpr optional<X> opt(X{});
static_assert((*opt).test() == 3, "");
}
{
- constexpr std::optional<Y> opt(Y{});
+ constexpr optional<Y> opt(Y{});
assert((*opt).test() == 2);
}
#ifdef _LIBCPP_DEBUG
{
- const std::optional<X> opt;
+ const optional<X> opt;
assert((*opt).test() == 3);
assert(false);
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp Fri Nov 15 16:42:10 2013
@@ -15,12 +15,14 @@
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
int test() const {return 2;}
@@ -33,12 +35,12 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- std::optional<X> opt(X{});
+ optional<X> opt(X{});
assert(opt->test() == 3);
}
#ifdef _LIBCPP_DEBUG
{
- std::optional<X> opt;
+ optional<X> opt;
assert(opt->test() == 3);
assert(false);
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp Fri Nov 15 16:42:10 2013
@@ -15,12 +15,14 @@
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
constexpr int test() const {return 3;}
@@ -43,20 +45,20 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- constexpr std::optional<X> opt(X{});
+ constexpr optional<X> opt(X{});
static_assert(opt->test() == 3, "");
}
{
- constexpr std::optional<Y> opt(Y{});
+ constexpr optional<Y> opt(Y{});
assert(opt->test() == 2);
}
{
- constexpr std::optional<Z> opt(Z{});
+ constexpr optional<Z> opt(Z{});
assert(opt->test() == 1);
}
#ifdef _LIBCPP_DEBUG
{
- const std::optional<X> opt;
+ const optional<X> opt;
assert(opt->test() == 3);
assert(false);
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,15 @@
// T& optional<T>::value();
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+using std::experimental::bad_optional_access;
+
struct X
{
X() = default;
@@ -31,18 +34,18 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- std::optional<X> opt;
+ optional<X> opt;
opt.emplace();
assert(opt.value().test() == 4);
}
{
- std::optional<X> opt;
+ optional<X> opt;
try
{
opt.value();
assert(false);
}
- catch (const std::bad_optional_access&)
+ catch (const bad_optional_access&)
{
}
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// constexpr const T& optional<T>::value() const;
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
constexpr int test() const {return 3;}
@@ -29,7 +31,7 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- constexpr std::optional<X> opt;
+ constexpr optional<X> opt;
static_assert(opt.value().test() == 3, "");
}
#else
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,17 @@
// constexpr const T& optional<T>::value() const;
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+using std::experimental::bad_optional_access;
+
struct X
{
X() = default;
@@ -31,21 +36,21 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- constexpr std::optional<X> opt(std::in_place);
+ constexpr optional<X> opt(in_place);
static_assert(opt.value().test() == 3, "");
}
{
- const std::optional<X> opt(std::in_place);
+ const optional<X> opt(in_place);
assert(opt.value().test() == 3);
}
{
- const std::optional<X> opt;
+ const optional<X> opt;
try
{
opt.value();
assert(false);
}
- catch (const std::bad_optional_access&)
+ catch (const bad_optional_access&)
{
}
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,16 @@
// template <class U> T optional<T>::value_or(U&& v) &&;
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
struct Y
{
int i_;
@@ -42,24 +46,24 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- std::optional<X> opt(std::in_place, 2);
+ optional<X> opt(in_place, 2);
Y y(3);
assert(std::move(opt).value_or(y) == 2);
assert(*opt == 0);
}
{
- std::optional<X> opt(std::in_place, 2);
+ optional<X> opt(in_place, 2);
assert(std::move(opt).value_or(Y(3)) == 2);
assert(*opt == 0);
}
{
- std::optional<X> opt;
+ optional<X> opt;
Y y(3);
assert(std::move(opt).value_or(y) == 3);
assert(!opt);
}
{
- std::optional<X> opt;
+ optional<X> opt;
assert(std::move(opt).value_or(Y(3)) == 4);
assert(!opt);
}
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// template <class U> constexpr T optional<T>::value_or(U&& v) const&;
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct Y
{
int i_;
@@ -41,39 +43,39 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- constexpr std::optional<X> opt(2);
+ constexpr optional<X> opt(2);
constexpr Y y(3);
static_assert(opt.value_or(y) == 2, "");
}
{
- constexpr std::optional<X> opt(2);
+ constexpr optional<X> opt(2);
static_assert(opt.value_or(Y(3)) == 2, "");
}
{
- constexpr std::optional<X> opt;
+ constexpr optional<X> opt;
constexpr Y y(3);
static_assert(opt.value_or(y) == 3, "");
}
{
- constexpr std::optional<X> opt;
+ constexpr optional<X> opt;
static_assert(opt.value_or(Y(3)) == 4, "");
}
{
- const std::optional<X> opt(2);
+ const optional<X> opt(2);
const Y y(3);
assert(opt.value_or(y) == 2);
}
{
- const std::optional<X> opt(2);
+ const optional<X> opt(2);
assert(opt.value_or(Y(3)) == 2);
}
{
- const std::optional<X> opt;
+ const optional<X> opt;
const Y y(3);
assert(opt.value_or(y) == 3);
}
{
- const std::optional<X> opt;
+ const optional<X> opt;
assert(opt.value_or(Y(3)) == 4);
}
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp Fri Nov 15 16:42:10 2013
@@ -13,12 +13,14 @@
// noexcept(is_nothrow_move_constructible<T>::value &&
// noexcept(swap(declval<T&>(), declval<T&>())));
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
class X
{
int i_;
@@ -67,8 +69,8 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- std::optional<int> opt1;
- std::optional<int> opt2;
+ optional<int> opt1;
+ optional<int> opt2;
static_assert(noexcept(opt1.swap(opt2)) == true, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == false);
@@ -77,8 +79,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<int> opt1(1);
- std::optional<int> opt2;
+ optional<int> opt1(1);
+ optional<int> opt2;
static_assert(noexcept(opt1.swap(opt2)) == true, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -89,8 +91,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<int> opt1;
- std::optional<int> opt2(2);
+ optional<int> opt1;
+ optional<int> opt2(2);
static_assert(noexcept(opt1.swap(opt2)) == true, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == true);
@@ -101,8 +103,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<int> opt1(1);
- std::optional<int> opt2(2);
+ optional<int> opt1(1);
+ optional<int> opt2(2);
static_assert(noexcept(opt1.swap(opt2)) == true, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -115,8 +117,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<X> opt1;
- std::optional<X> opt2;
+ optional<X> opt1;
+ optional<X> opt2;
static_assert(noexcept(opt1.swap(opt2)) == true, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == false);
@@ -126,8 +128,8 @@ int main()
assert(X::dtor_called == 0);
}
{
- std::optional<X> opt1(1);
- std::optional<X> opt2;
+ optional<X> opt1(1);
+ optional<X> opt2;
static_assert(noexcept(opt1.swap(opt2)) == true, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -140,8 +142,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<X> opt1;
- std::optional<X> opt2(2);
+ optional<X> opt1;
+ optional<X> opt2(2);
static_assert(noexcept(opt1.swap(opt2)) == true, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == true);
@@ -154,8 +156,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<X> opt1(1);
- std::optional<X> opt2(2);
+ optional<X> opt1(1);
+ optional<X> opt2(2);
static_assert(noexcept(opt1.swap(opt2)) == true, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -170,8 +172,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<Y> opt1;
- std::optional<Y> opt2;
+ optional<Y> opt1;
+ optional<Y> opt2;
static_assert(noexcept(opt1.swap(opt2)) == false, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == false);
@@ -181,8 +183,8 @@ int main()
assert(Y::dtor_called == 0);
}
{
- std::optional<Y> opt1(1);
- std::optional<Y> opt2;
+ optional<Y> opt1(1);
+ optional<Y> opt2;
static_assert(noexcept(opt1.swap(opt2)) == false, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -195,8 +197,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<Y> opt1;
- std::optional<Y> opt2(2);
+ optional<Y> opt1;
+ optional<Y> opt2(2);
static_assert(noexcept(opt1.swap(opt2)) == false, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == true);
@@ -209,8 +211,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<Y> opt1(1);
- std::optional<Y> opt2(2);
+ optional<Y> opt1(1);
+ optional<Y> opt2(2);
static_assert(noexcept(opt1.swap(opt2)) == false, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -225,8 +227,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<Z> opt1;
- std::optional<Z> opt2;
+ optional<Z> opt1;
+ optional<Z> opt2;
static_assert(noexcept(opt1.swap(opt2)) == false, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == false);
@@ -235,9 +237,9 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<Z> opt1;
+ optional<Z> opt1;
opt1.emplace(1);
- std::optional<Z> opt2;
+ optional<Z> opt2;
static_assert(noexcept(opt1.swap(opt2)) == false, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -256,8 +258,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<Z> opt1;
- std::optional<Z> opt2;
+ optional<Z> opt1;
+ optional<Z> opt2;
opt2.emplace(2);
static_assert(noexcept(opt1.swap(opt2)) == false, "");
assert(static_cast<bool>(opt1) == false);
@@ -277,9 +279,9 @@ int main()
assert(*opt2 == 2);
}
{
- std::optional<Z> opt1;
+ optional<Z> opt1;
opt1.emplace(1);
- std::optional<Z> opt2;
+ optional<Z> opt2;
opt2.emplace(2);
static_assert(noexcept(opt1.swap(opt2)) == false, "");
assert(static_cast<bool>(opt1) == true);
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional_const_void.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional_const_void.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional_const_void.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional_const_void.fail.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// T shall be an object type and shall satisfy the requirements of Destructible
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<const void> opt;
+ using std::experimental::optional;
+
+ optional<const void> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp Fri Nov 15 16:42:10 2013
@@ -11,10 +11,12 @@
// T shall be an object type and shall satisfy the requirements of Destructible
-#include <optional>
+#include <experimental/optional>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
private:
@@ -26,7 +28,7 @@ private:
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<X> opt;
+ optional<X> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp Fri Nov 15 16:42:10 2013
@@ -11,10 +11,12 @@
// T shall be an object type and shall satisfy the requirements of Destructible
-#include <optional>
+#include <experimental/optional>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
~X() noexcept(false) {}
@@ -25,7 +27,7 @@ struct X
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<X> opt;
+ optional<X> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.object/optional_void.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/optional_void.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/optional_void.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/optional_void.fail.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// T shall be an object type and shall satisfy the requirements of Destructible
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<void> opt;
+ using std::experimental::optional;
+
+ optional<void> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.object/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.object/types.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.object/types.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.object/types.pass.cpp Fri Nov 15 16:42:10 2013
@@ -16,11 +16,13 @@
// typedef T value_type;
// ...
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
template <class Opt, class T>
void
test()
@@ -33,9 +35,9 @@ test()
int main()
{
#if _LIBCPP_STD_VER > 11
- test<std::optional<int>, int>();
- test<std::optional<const int>, const int>();
- test<std::optional<double>, double>();
- test<std::optional<const double>, const double>();
+ test<optional<int>, int>();
+ test<optional<const int>, const int>();
+ test<optional<double>, double>();
+ test<optional<const double>, const double>();
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.relops/equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.relops/equal.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.relops/equal.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.relops/equal.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,12 +11,14 @@
// template <class T> constexpr bool operator==(const optional<T>& x, const optional<T>& y);
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
int i_;
@@ -34,7 +36,7 @@ int main()
#if _LIBCPP_STD_VER > 11
{
typedef X T;
- typedef std::optional<T> O;
+ typedef optional<T> O;
constexpr O o1; // disengaged
constexpr O o2; // disengaged
Modified: libcxx/trunk/test/utilities/optional/optional.relops/less_than.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.relops/less_than.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.relops/less_than.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.relops/less_than.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,10 +11,12 @@
// template <class T> constexpr bool operator< (const optional<T>& x, const optional<T>& y);
-#include <optional>
+#include <experimental/optional>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
struct X
{
int i_;
@@ -31,7 +33,7 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- typedef std::optional<X> O;
+ typedef optional<X> O;
constexpr O o1; // disengaged
constexpr O o2; // disengaged
Modified: libcxx/trunk/test/utilities/optional/optional.specalg/make_optional.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.specalg/make_optional.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.specalg/make_optional.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.specalg/make_optional.pass.cpp Fri Nov 15 16:42:10 2013
@@ -14,36 +14,35 @@
// optional<typename decay<T>::type>
// make_optional(T&& v);
-#include <optional>
+#include <experimental/optional>
#include <string>
#include <memory>
#include <cassert>
-#if _LIBCPP_STD_VER > 11
-
-#endif // _LIBCPP_STD_VER > 11
-
int main()
{
#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::make_optional;
+
{
- std::optional<int> opt = std::make_optional(2);
+ optional<int> opt = make_optional(2);
assert(*opt == 2);
}
{
std::string s("123");
- std::optional<std::string> opt = std::make_optional(s);
+ optional<std::string> opt = make_optional(s);
assert(*opt == s);
}
{
std::string s("123");
- std::optional<std::string> opt = std::make_optional(std::move(s));
+ optional<std::string> opt = make_optional(std::move(s));
assert(*opt == "123");
assert(s.empty());
}
{
std::unique_ptr<int> s(new int(3));
- std::optional<std::unique_ptr<int>> opt = std::make_optional(std::move(s));
+ optional<std::unique_ptr<int>> opt = make_optional(std::move(s));
assert(**opt == 3);
assert(s == nullptr);
}
Modified: libcxx/trunk/test/utilities/optional/optional.specalg/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.specalg/swap.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.specalg/swap.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.specalg/swap.pass.cpp Fri Nov 15 16:42:10 2013
@@ -12,12 +12,14 @@
// template <class T> void swap(optional<T>& x, optional<T>& y)
// noexcept(noexcept(x.swap(y)));
-#include <optional>
+#include <experimental/optional>
#include <type_traits>
#include <cassert>
#if _LIBCPP_STD_VER > 11
+using std::experimental::optional;
+
class X
{
int i_;
@@ -66,8 +68,8 @@ int main()
{
#if _LIBCPP_STD_VER > 11
{
- std::optional<int> opt1;
- std::optional<int> opt2;
+ optional<int> opt1;
+ optional<int> opt2;
static_assert(noexcept(swap(opt1, opt2)) == true, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == false);
@@ -76,8 +78,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<int> opt1(1);
- std::optional<int> opt2;
+ optional<int> opt1(1);
+ optional<int> opt2;
static_assert(noexcept(swap(opt1, opt2)) == true, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -88,8 +90,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<int> opt1;
- std::optional<int> opt2(2);
+ optional<int> opt1;
+ optional<int> opt2(2);
static_assert(noexcept(swap(opt1, opt2)) == true, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == true);
@@ -100,8 +102,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<int> opt1(1);
- std::optional<int> opt2(2);
+ optional<int> opt1(1);
+ optional<int> opt2(2);
static_assert(noexcept(swap(opt1, opt2)) == true, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -114,8 +116,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<X> opt1;
- std::optional<X> opt2;
+ optional<X> opt1;
+ optional<X> opt2;
static_assert(noexcept(swap(opt1, opt2)) == true, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == false);
@@ -125,8 +127,8 @@ int main()
assert(X::dtor_called == 0);
}
{
- std::optional<X> opt1(1);
- std::optional<X> opt2;
+ optional<X> opt1(1);
+ optional<X> opt2;
static_assert(noexcept(swap(opt1, opt2)) == true, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -139,8 +141,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<X> opt1;
- std::optional<X> opt2(2);
+ optional<X> opt1;
+ optional<X> opt2(2);
static_assert(noexcept(swap(opt1, opt2)) == true, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == true);
@@ -153,8 +155,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<X> opt1(1);
- std::optional<X> opt2(2);
+ optional<X> opt1(1);
+ optional<X> opt2(2);
static_assert(noexcept(swap(opt1, opt2)) == true, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -169,8 +171,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<Y> opt1;
- std::optional<Y> opt2;
+ optional<Y> opt1;
+ optional<Y> opt2;
static_assert(noexcept(swap(opt1, opt2)) == false, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == false);
@@ -180,8 +182,8 @@ int main()
assert(Y::dtor_called == 0);
}
{
- std::optional<Y> opt1(1);
- std::optional<Y> opt2;
+ optional<Y> opt1(1);
+ optional<Y> opt2;
static_assert(noexcept(swap(opt1, opt2)) == false, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -194,8 +196,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<Y> opt1;
- std::optional<Y> opt2(2);
+ optional<Y> opt1;
+ optional<Y> opt2(2);
static_assert(noexcept(swap(opt1, opt2)) == false, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == true);
@@ -208,8 +210,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<Y> opt1(1);
- std::optional<Y> opt2(2);
+ optional<Y> opt1(1);
+ optional<Y> opt2(2);
static_assert(noexcept(swap(opt1, opt2)) == false, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -224,8 +226,8 @@ int main()
assert(*opt2 == 1);
}
{
- std::optional<Z> opt1;
- std::optional<Z> opt2;
+ optional<Z> opt1;
+ optional<Z> opt2;
static_assert(noexcept(swap(opt1, opt2)) == false, "");
assert(static_cast<bool>(opt1) == false);
assert(static_cast<bool>(opt2) == false);
@@ -234,9 +236,9 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<Z> opt1;
+ optional<Z> opt1;
opt1.emplace(1);
- std::optional<Z> opt2;
+ optional<Z> opt2;
static_assert(noexcept(swap(opt1, opt2)) == false, "");
assert(static_cast<bool>(opt1) == true);
assert(*opt1 == 1);
@@ -255,8 +257,8 @@ int main()
assert(static_cast<bool>(opt2) == false);
}
{
- std::optional<Z> opt1;
- std::optional<Z> opt2;
+ optional<Z> opt1;
+ optional<Z> opt2;
opt2.emplace(2);
static_assert(noexcept(swap(opt1, opt2)) == false, "");
assert(static_cast<bool>(opt1) == false);
@@ -276,9 +278,9 @@ int main()
assert(*opt2 == 2);
}
{
- std::optional<Z> opt1;
+ optional<Z> opt1;
opt1.emplace(1);
- std::optional<Z> opt2;
+ optional<Z> opt2;
opt2.emplace(2);
static_assert(noexcept(swap(opt1, opt2)) == false, "");
assert(static_cast<bool>(opt1) == true);
Modified: libcxx/trunk/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp Fri Nov 15 16:42:10 2013
@@ -12,12 +12,16 @@
// A program that necessitates the instantiation of template optional for
// (possibly cv-qualified) in_place_t is ill-formed.
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<const std::inplace_t> opt;
+ using std::experimental::optional;
+ using std::experimental::in_place_t;
+ using std::experimental::in_place;
+
+ optional<const in_place_t> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp Fri Nov 15 16:42:10 2013
@@ -12,12 +12,14 @@
// A program that necessitates the instantiation of template optional for a
// reference type is ill-formed.
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<const int&> opt;
+ using std::experimental::optional;
+
+ optional<const int&> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp Fri Nov 15 16:42:10 2013
@@ -12,12 +12,16 @@
// A program that necessitates the instantiation of template optional for
// (possibly cv-qualified) null_opt_t is ill-formed.
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<const std::nullopt_t> opt;
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ optional<const nullopt_t> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp Fri Nov 15 16:42:10 2013
@@ -12,12 +12,16 @@
// A program that necessitates the instantiation of template optional for
// (possibly cv-qualified) in_place_t is ill-formed.
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<std::inplace_t> opt;
+ using std::experimental::optional;
+ using std::experimental::in_place_t;
+ using std::experimental::in_place;
+
+ optional<in_place_t> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp Fri Nov 15 16:42:10 2013
@@ -11,11 +11,13 @@
// #include <initializer_list>
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
std::initializer_list<int> list;
#endif // _LIBCPP_STD_VER > 11
}
Modified: libcxx/trunk/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp Fri Nov 15 16:42:10 2013
@@ -12,12 +12,14 @@
// A program that necessitates the instantiation of template optional for a
// reference type is ill-formed.
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<int&> opt;
+ using std::experimental::optional;
+
+ optional<int&> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp Fri Nov 15 16:42:10 2013
@@ -12,12 +12,16 @@
// A program that necessitates the instantiation of template optional for
// (possibly cv-qualified) null_opt_t is ill-formed.
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<std::nullopt_t> opt;
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ optional<nullopt_t> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp (original)
+++ libcxx/trunk/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp Fri Nov 15 16:42:10 2013
@@ -12,12 +12,14 @@
// A program that necessitates the instantiation of template optional for a
// reference type is ill-formed.
-#include <optional>
+#include <experimental/optional>
int main()
{
#if _LIBCPP_STD_VER > 11
- std::optional<int&&> opt;
+ using std::experimental::optional;
+
+ optional<int&&> opt;
#else
#error
#endif // _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/optional/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/optional/version.pass.cpp?rev=194867&r1=194866&r2=194867&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/optional/version.pass.cpp (original)
+++ libcxx/trunk/test/utilities/optional/version.pass.cpp Fri Nov 15 16:42:10 2013
@@ -9,7 +9,7 @@
// <optional>
-#include <optional>
+#include <experimental/optional>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
More information about the cfe-commits
mailing list