Commit b01af236 by Tim Shen Committed by Tim Shen

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
parent 458ef690
2016-11-27 Tim Shen <timshen@google.com>
* 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.
2016-12-07 Tim Shen <timshen@google.com>
* include/bits/enable_special_members.h: Make
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment