diff options
author | Tim Shen <timshen@google.com> | 2016-12-06 11:28:09 +0000 |
---|---|---|
committer | Tim Shen <timshen@gcc.gnu.org> | 2016-12-06 11:28:09 +0000 |
commit | b01af236b7d0d92cf1e9d642495d9177347bd740 (patch) | |
tree | 7f0ce37f889944d73231296ffa53c7648bd8ceb0 /libstdc++-v3/testsuite/20_util/variant/compile.cc | |
parent | 458ef69052224b5d3d2c78cfbe0a0e0ec85a4193 (diff) | |
download | gcc-b01af236b7d0d92cf1e9d642495d9177347bd740.tar.gz |
variant (visit): Make visit constexpr.
* include/std/variant (visit): Make visit constexpr. Also cleanup
__get_alternative and __storage, since we don't support reference/void
alternatives any more.
* testsuite/20_util/variant/compile.cc: Add tests.
From-SVN: r243295
Diffstat (limited to 'libstdc++-v3/testsuite/20_util/variant/compile.cc')
-rw-r--r-- | libstdc++-v3/testsuite/20_util/variant/compile.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc index 087a17cb952..a8ffaeaaecc 100644 --- a/libstdc++-v3/testsuite/20_util/variant/compile.cc +++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc @@ -275,6 +275,22 @@ void test_visit() }; visit(Visitor(), variant<int, char>(), variant<float, double>()); } + { + struct Visitor + { + constexpr bool operator()(const int&) { return true; } + constexpr bool operator()(const nonliteral&) { return false; } + }; + static_assert(visit(Visitor(), variant<int, nonliteral>(0)), ""); + } + { + struct Visitor + { + constexpr bool operator()(const int&) { return true; } + constexpr bool operator()(const nonliteral&) { return false; } + }; + static_assert(visit(Visitor(), variant<int, nonliteral>(0)), ""); + } } void test_constexpr() |