Files

59 lines
1.2 KiB
C++
Raw Permalink Normal View History

2026-07-24 17:51:07 +03:00
// Copyright 2026 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if defined(BOOST_MSVC) && BOOST_MSVC < 1920
BOOST_PRAGMA_MESSAGE( "Test skipped, because BOOST_MSVC < 1920" )
int main() {}
#else
2026-07-24 17:51:07 +03:00
#include <boost/variant2/variant.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/mp11.hpp>
2026-07-24 18:08:34 +03:00
using boost::variant2::detail::has_ne;
2026-07-24 17:51:07 +03:00
using namespace boost::variant2;
struct X1
{
};
struct X2
{
bool operator!=( X2 const& ) const = delete;
};
struct X3
{
void operator!=( X3 const& ) const;
};
2026-07-24 20:22:51 +03:00
struct X4
{
bool operator!=( X4 const& ) const;
};
2026-07-24 17:51:07 +03:00
int main()
{
2026-07-24 18:08:34 +03:00
BOOST_TEST_TRAIT_FALSE(( has_ne< X1 > ));
BOOST_TEST_TRAIT_FALSE(( has_ne< X2 > ));
BOOST_TEST_TRAIT_FALSE(( has_ne< X3 > ));
2026-07-24 20:22:51 +03:00
BOOST_TEST_TRAIT_TRUE(( has_ne< X4 > ));
2026-07-24 18:08:34 +03:00
2026-07-24 17:51:07 +03:00
BOOST_TEST_TRAIT_FALSE(( has_ne< variant<X1> > ));
BOOST_TEST_TRAIT_FALSE(( has_ne< variant<X2> > ));
BOOST_TEST_TRAIT_FALSE(( has_ne< variant<X3> > ));
2026-07-24 20:22:51 +03:00
BOOST_TEST_TRAIT_TRUE(( has_ne< variant<X4> > ));
2026-07-24 17:51:07 +03:00
return boost::report_errors();
}
#endif