forked from boostorg/variant2
Add operator<< for monostate
This commit is contained in:
@ -30,9 +30,12 @@ int main()
|
||||
BOOST_TEST_TRAIT_FALSE((boost::variant2::detail::is_output_streamable<std::ostream, X>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::variant2::detail::is_output_streamable<std::ostream, Y>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((boost::variant2::detail::is_output_streamable<std::ostream, boost::variant2::monostate>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((boost::variant2::detail::is_output_streamable<std::ostream, boost::variant2::variant<int, float, std::string>>));
|
||||
BOOST_TEST_TRAIT_FALSE((boost::variant2::detail::is_output_streamable<std::ostream, boost::variant2::variant<int, float, X>>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::variant2::detail::is_output_streamable<std::ostream, boost::variant2::variant<int, float, Y>>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::variant2::detail::is_output_streamable<std::ostream, boost::variant2::variant<boost::variant2::monostate, int, float>>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -20,17 +20,24 @@ template<class T> std::string to_string( T const& t )
|
||||
|
||||
int main()
|
||||
{
|
||||
variant<int, float, std::string> v( 1 );
|
||||
{
|
||||
BOOST_TEST_EQ( to_string( monostate() ), "monostate" );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( to_string( v ), to_string( 1 ) );
|
||||
{
|
||||
variant<monostate, int, float, std::string> v;
|
||||
|
||||
v = 3.14f;
|
||||
BOOST_TEST_EQ( to_string( v ), to_string( monostate() ) );
|
||||
|
||||
BOOST_TEST_EQ( to_string( v ), to_string( 3.14f ) );
|
||||
v = 1;
|
||||
BOOST_TEST_EQ( to_string( v ), to_string( 1 ) );
|
||||
|
||||
v = "test";
|
||||
v = 3.14f;
|
||||
BOOST_TEST_EQ( to_string( v ), to_string( 3.14f ) );
|
||||
|
||||
BOOST_TEST_EQ( to_string( v ), to_string( "test" ) );
|
||||
v = "test";
|
||||
BOOST_TEST_EQ( to_string( v ), to_string( "test" ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user