forked from boostorg/variant2
Add test for inherited constructors (refs #26)
This commit is contained in:
@ -119,3 +119,5 @@ run variant_visit_r.cpp : : :
|
|||||||
<toolset>gcc,<target-os>windows:<variant>release
|
<toolset>gcc,<target-os>windows:<variant>release
|
||||||
<toolset>gcc,<target-os>cygwin:<variant>release
|
<toolset>gcc,<target-os>cygwin:<variant>release
|
||||||
;
|
;
|
||||||
|
|
||||||
|
compile variant_derived_construct.cpp ;
|
||||||
|
33
test/variant_derived_construct.cpp
Normal file
33
test/variant_derived_construct.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright 2021 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/variant2/variant.hpp>
|
||||||
|
|
||||||
|
using namespace boost::variant2;
|
||||||
|
|
||||||
|
template<class... T> class X: variant<T...>
|
||||||
|
{
|
||||||
|
using base = variant<T...>;
|
||||||
|
using base::base;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Y
|
||||||
|
{
|
||||||
|
Y( Y const& rhs ) = default;
|
||||||
|
|
||||||
|
template<class T> Y( T const& t )
|
||||||
|
{
|
||||||
|
t.bar();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using W = X<int, double, Y>;
|
||||||
|
|
||||||
|
W a( 1 );
|
||||||
|
W b( a );
|
||||||
|
|
||||||
|
(void)b;
|
||||||
|
}
|
Reference in New Issue
Block a user