diff --git a/test/Jamfile b/test/Jamfile index 85788b9..b9b3d9c 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -133,3 +133,5 @@ run variant_json_value_from.cpp : : : $(JSON) ; run variant_json_value_to.cpp : : : $(JSON) ; compile variant_uses_double_storage.cpp ; + +run variant_derived_construct2.cpp ; diff --git a/test/variant_derived_construct2.cpp b/test/variant_derived_construct2.cpp new file mode 100644 index 0000000..31488aa --- /dev/null +++ b/test/variant_derived_construct2.cpp @@ -0,0 +1,60 @@ +// Copyright 2024 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +struct expr: boost::variant2::variant +{ + using variant::variant; +}; + +int main() +{ + using boost::variant2::get; + + { + expr v{ true }; + + BOOST_TEST_EQ( v.index(), 0 ); + BOOST_TEST_EQ( get<0>(v), true ); + } + + { + expr v{ 2 }; + + BOOST_TEST_EQ( v.index(), 1 ); + BOOST_TEST_EQ( get<1>(v), 2 ); + } + + { + expr v{ 3.0 }; + + BOOST_TEST_EQ( v.index(), 2 ); + BOOST_TEST_EQ( get<2>(v), 3.0 ); + } + + { + expr v( true ); + + BOOST_TEST_EQ( v.index(), 0 ); + BOOST_TEST_EQ( get<0>(v), true ); + } + + { + expr v( 2 ); + + BOOST_TEST_EQ( v.index(), 1 ); + BOOST_TEST_EQ( get<1>(v), 2 ); + } + + { + expr v( 3.0 ); + + BOOST_TEST_EQ( v.index(), 2 ); + BOOST_TEST_EQ( get<2>(v), 3.0 ); + } + + return boost::report_errors(); +}