On Mon, 8 Apr 2019 at 07:30, Gavin Lambert via Boost
wrote:
Or did you mean to check is_nothrow_constructible rather than
is_trivially_constructible?
(Also, for robustness you should check assignment as well as construction.)
Just now I'm at it:
#include
#include <variant>
#include
#include
namespace mp11 = boost::mp11;
struct Foo {
Foo ( ) = delete;
};
template
struct safe_std_variant : public std::variant {
static_assert (
std::conjunction::value, "is not
trivially constructible" );
};
template
struct safe_boost_variant : public boost::variant {
static_assert (
mp11::mp_all::value, "is not
trivially constructible" );
};
template
struct evensafer_std_variant : public std::variant {
static_assert (
std::conjunction,
std::conjunction>::value,
"is not trivially constructible or copy assignable" );
};
template
struct evensafer_boost_variant : public boost::variant {
static_assert (
mp11::mp_all,
mp11::mp_all>::value,
"is not trivially constructible or copy assignable" );
};
int main ( ) {
safe_std_variant sv1; // compiles
safe_boost_variant sv2; // compiles
evensafer_std_variant sv3; // compiles
evensafer_boost_variant sv4; // compiles
// safe_std_variant sv5; // does not
compile
// safe_boost_variant sv6; // does not
compile
// evensafer_std_variant sv7; // does not
compile
// evensafer_boost_variant sv8; // does not
compile
}
degski
--
*Microsoft, please kill Paint3D*