135ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier//===----------------------------------------------------------------------===//
235ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier//
335ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier//                     The LLVM Compiler Infrastructure
435ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier//
535ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier// This file is dual licensed under the MIT and the University of Illinois Open
635ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier// Source Licenses. See LICENSE.TXT for details.
735ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier//
835ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier//===----------------------------------------------------------------------===//
935ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier
1035ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier// UNSUPPORTED: c++98, c++03, c++11, c++14
1135ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier// <optional>
1235ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier
1335ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier// struct nullopt_t{see below};
1435ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier// constexpr nullopt_t nullopt(unspecified);
1535ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier
16a5f53d07302a3da5f1f28343cab610de005777a6Marshall Clow// [optional.nullopt]/2:
17a5f53d07302a3da5f1f28343cab610de005777a6Marshall Clow//   Type nullopt_t shall not have a default constructor or an initializer-list constructor.
18fdbd18ff71c976643380d5cf0ac8580487123b2dStephan T. Lavavej//   It shall not be an aggregate and shall be a literal type.
19a5f53d07302a3da5f1f28343cab610de005777a6Marshall Clow//   Constant nullopt shall be initialized with an argument of literal type.
20a5f53d07302a3da5f1f28343cab610de005777a6Marshall Clow
2135ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier#include <optional>
2235ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier#include <type_traits>
2335ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier
2435ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselierusing std::optional;
2535ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselierusing std::nullopt_t;
2635ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselierusing std::nullopt;
2735ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier
2835ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselierconstexpr
2935ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselierint
3035ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiseliertest(const nullopt_t&)
3135ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier{
3235ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier    return 3;
3335ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier}
3435ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier
3535ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselierint main()
3635ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier{
37a5f53d07302a3da5f1f28343cab610de005777a6Marshall Clow    static_assert(( std::is_class<nullopt_t>::value), "");
38a5f53d07302a3da5f1f28343cab610de005777a6Marshall Clow    static_assert(( std::is_empty<nullopt_t>::value), "");
39a5f53d07302a3da5f1f28343cab610de005777a6Marshall Clow    static_assert(( std::is_literal_type<nullopt_t>::value), "");
4035ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier    static_assert((!std::is_default_constructible<nullopt_t>::value), "");
4135ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier
4235ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier    static_assert(test(nullopt) == 3, "");
4335ce4859dd7cc2b7ed280cecc0fe0d9cabe6461bEric Fiselier}
44