Add initializer list support

This commit is contained in:
Peter Dimov
2017-05-31 04:19:40 +03:00
parent 8301228e22
commit 755bc60c2b
5 changed files with 67 additions and 7 deletions
+16 -2
View File
@@ -17,8 +17,8 @@ using namespace boost::variant2;
struct X
{
X() = default;
X( in_place_index_t<0> ) = delete;
X() = default;
X( in_place_index_t<0> ) = delete;
};
int main()
@@ -120,5 +120,19 @@ int main()
BOOST_TEST_EQ( get<5>(v), std::string( 4, 'a' ) );
}
{
variant<int, int, float, float, std::string, std::string> v( in_place_index<4>, { 'a', 'b', 'c' } );
BOOST_TEST_EQ( v.index(), 4 );
BOOST_TEST_EQ( get<4>(v), (std::string{ 'a', 'b', 'c' }) );
}
{
variant<int, int, float, float, std::string, std::string> v( in_place_index<5>, { 'a', 'b', 'c' }, std::allocator<char>() );
BOOST_TEST_EQ( v.index(), 5 );
BOOST_TEST_EQ( get<5>(v), (std::string{ 'a', 'b', 'c' }) );
}
return boost::report_errors();
}