From f586dc88484fea8ad790218c9f02489aa936015b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 12 Mar 2021 20:15:09 +0200 Subject: [PATCH] Add test for inherited constructors (refs #26) --- test/Jamfile | 2 ++ test/variant_derived_construct.cpp | 33 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/variant_derived_construct.cpp diff --git a/test/Jamfile b/test/Jamfile index 682b862..d104a1b 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -119,3 +119,5 @@ run variant_visit_r.cpp : : : gcc,windows:release gcc,cygwin:release ; + +compile variant_derived_construct.cpp ; diff --git a/test/variant_derived_construct.cpp b/test/variant_derived_construct.cpp new file mode 100644 index 0000000..6844336 --- /dev/null +++ b/test/variant_derived_construct.cpp @@ -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 + +using namespace boost::variant2; + +template class X: variant +{ + using base = variant; + using base::base; +}; + +struct Y +{ + Y( Y const& rhs ) = default; + + template Y( T const& t ) + { + t.bar(); + } +}; + +int main() +{ + using W = X; + + W a( 1 ); + W b( a ); + + (void)b; +}