Move <optional> into include/experimental, and into the std::experimental namespace, since it's not part of C++14, but of an upcoming TS

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@194867 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2013-11-15 22:42:10 +00:00
parent ec5714f27a
commit 0cdbe60481
59 changed files with 523 additions and 409 deletions

View File

@@ -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