// Copyright 2024 Joaquin M Lopez Munoz. // // Distributed under the Boost Software License, Version 1.0. // // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt #include #if BOOST_MP11_WORKAROUND(BOOST_MP11_MSVC, <= 1800) #pragma message("Test skipped because BOOST_MP11_MSVC <= 1800") int main() {} #else #include #include #include #include #include struct X; enum E {}; #if BOOST_MP11_WORKAROUND(BOOST_MP11_GCC, < 40900) // A bug in GCC < 4.9 results in const/volatile qualifiers being stripped #define CONST #define VOLATILE #else #define CONST const #define VOLATILE volatile #endif int main() { using namespace boost::mp11; BOOST_TEST_TRAIT_TRUE((std::is_same::fn<>, int>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int*>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn<>, X>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, X>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, X*>)); #if !BOOST_MP11_WORKAROUND(BOOST_MP11_GCC, < 40900) // GCC < 4.9 ICEs when dealing with enum types BOOST_TEST_TRAIT_TRUE((std::is_same::fn, E>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, E*>)); #endif BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int CONST>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int VOLATILE>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int CONST VOLATILE>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int*>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int CONST*>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int CONST* CONST>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, void CONST*>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int VOLATILE *&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int VOLATILE *&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int[]>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int[5]>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int*[][5]>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char, double)>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char)>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, void()>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char, char*)>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(*[])(char)>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char, ...)>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(X::*)(char, ...)>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char)>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) volatile>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const volatile>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char)&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) volatile&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const volatile&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char)&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) volatile&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const volatile&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) volatile noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const volatile noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char)& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) volatile& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const volatile& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char)&& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const&& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) volatile&& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int(char) const volatile&& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char)>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) volatile>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const volatile>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char)&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) volatile&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const volatile&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char)&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) volatile&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const volatile&&>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) volatile noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const volatile noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char)& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) volatile& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const volatile& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char)&& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const&& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) volatile&& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int (X::*)(char) const volatile&& noexcept>)); BOOST_TEST_TRAIT_TRUE((std::is_same::fn, int X::*>)); BOOST_TEST_TRAIT_TRUE((std::is_same>::fn, std::pair>)); BOOST_TEST_TRAIT_TRUE((std::is_same>::fn, std::pair>)); BOOST_TEST_TRAIT_TRUE((std::is_same>::fn, std::pair>)); BOOST_TEST_TRAIT_TRUE((std::is_same>::fn, std::tuple>)); BOOST_TEST_TRAIT_TRUE((std::is_same*>::fn, std::tuple*>)); BOOST_TEST_TRAIT_TRUE((std::is_same*>::fn, std::tuple*>)); BOOST_TEST_TRAIT_TRUE((std::is_same>>::fn, std::tuple>>)); BOOST_TEST_TRAIT_TRUE((std::is_same>::fn<_2, _1>, std::tuple<_2, _1>>)); BOOST_TEST_TRAIT_TRUE((std::is_same>::fn, mp_bind>)); // return boost::report_errors(); } #endif