diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-11-23 01:02:51 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-11-23 01:02:51 +0000 |
commit | 80e66ac1d3cdb67a35ca0c57f8e4a00cacd0f019 (patch) | |
tree | 370e5d119c4f7c459428f538bfdeb677ac1caaa7 /libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp | |
parent | be6c2f1a36d8e7a720653bbb79ae494b6b68e99c (diff) | |
download | bcm5719-llvm-80e66ac1d3cdb67a35ca0c57f8e4a00cacd0f019.tar.gz bcm5719-llvm-80e66ac1d3cdb67a35ca0c57f8e4a00cacd0f019.zip |
Add <variant> tests but disable them for libc++
llvm-svn: 287728
Diffstat (limited to 'libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp')
-rw-r--r-- | libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp b/libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp new file mode 100644 index 00000000000..1871c1064b4 --- /dev/null +++ b/libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp @@ -0,0 +1,77 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// <variant> + +// template <size_t I, class T> struct variant_alternative; // undefined +// template <size_t I, class T> struct variant_alternative<I, const T>; +// template <size_t I, class T> struct variant_alternative<I, volatile T>; +// template <size_t I, class T> struct variant_alternative<I, const volatile T>; +// template <size_t I, class T> +// using variant_alternative_t = typename variant_alternative<I, T>::type; +// +// template <size_t I, class... Types> +// struct variant_alternative<I, variant<Types...>>; + +#include <memory> +#include <type_traits> +#include <variant> + +#include "test_macros.h" +#include "variant_test_helpers.hpp" + +template <class V, size_t I, class E> void test() { + static_assert( + std::is_same_v<typename std::variant_alternative<I, V>::type, E>, ""); + static_assert( + std::is_same_v<typename std::variant_alternative<I, const V>::type, + const E>, + ""); + static_assert( + std::is_same_v<typename std::variant_alternative<I, volatile V>::type, + volatile E>, + ""); + static_assert( + std::is_same_v< + typename std::variant_alternative<I, const volatile V>::type, + const volatile E>, + ""); + static_assert(std::is_same_v<std::variant_alternative_t<I, V>, E>, ""); + static_assert(std::is_same_v<std::variant_alternative_t<I, const V>, const E>, + ""); + static_assert( + std::is_same_v<std::variant_alternative_t<I, volatile V>, volatile E>, + ""); + static_assert(std::is_same_v<std::variant_alternative_t<I, const volatile V>, + const volatile E>, + ""); +} + +int main() { + { + using V = std::variant<int, void *, const void *, long double>; + test<V, 0, int>(); + test<V, 1, void *>(); + test<V, 2, const void *>(); + test<V, 3, long double>(); + } +#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) + { + using V = std::variant<int, int &, int const &, int &&, long double>; + test<V, 0, int>(); + test<V, 1, int &>(); + test<V, 2, int const &>(); + test<V, 3, int &&>(); + test<V, 4, long double>(); + } +#endif +} |