File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -92,26 +92,32 @@ inline std::ostream & operator<<( std::ostream & os, V const & v )
9292
9393class NoDefaultConstruct { NoDefaultConstruct(){} };
9494
95+ struct BlowOnAssign
96+ {
97+ BlowOnAssign () {}
98+ BlowOnAssign ( BlowOnAssign const & ) { throw 42 ; }
99+ BlowOnAssign & operator =( BlowOnAssign const & ) { return *this ; }
95100#if variant_CPP11_OR_GREATER
101+ BlowOnAssign ( BlowOnAssign && ) { throw 42 ; }
102+ BlowOnAssign & operator =( BlowOnAssign && ) = default ;
103+ #endif
104+ };
96105
97- using empty_variant_t = variant<char , int > ;
106+ typedef variant<char , BlowOnAssign> empty_variant_t ;
98107
99108empty_variant_t make_empty_variant ()
100109{
101- struct Blow { operator int () { throw 42 ; } } ;
110+ empty_variant_t var = ' a ' ;
102111
103- empty_variant_t var;
104-
105- try { var.emplace <1 >( Blow () ); } catch (...) {}
112+ try { var = BlowOnAssign (); } catch (...) {}
106113
107114 return var;
108115}
109116
110117empty_variant_t make_non_empty_variant ()
111118{
112- return { 7 } ;
119+ return empty_variant_t ( ' a ' ) ;
113120}
114- #endif
115121
116122} // anonymous namespace
117123
You can’t perform that action at this time.
0 commit comments