// Copyright Louis Dionne 2013-2017 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include namespace hana = boost::hana; int main() { // Unsigned integral constants should hash to `unsigned long long` { BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); } // Signed integral constants should hash to `signed long long` { BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); } // `char` should hash to either `signed long long` or `unsigned long long`, // depending on its signedness { using T = std::conditional_t< std::is_signed::value, signed long long, unsigned long long >; BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::integral_c), hana::type_c> )); } // Pointers to members should hash to themselves. // This test is disabled in pre-C++17, because pointers to non-static // data members can't be used as non-type template arguments before that. // See http://stackoverflow.com/q/35398848/627587. { #if __cplusplus > 201402L struct Foo { int bar; }; constexpr auto x = hana::integral_constant{}; BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(x), hana::type_c> )); #endif } // Booleans should hash to themselves { BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::true_c), hana::type_c )); BOOST_HANA_CONSTANT_ASSERT(hana::equal( hana::hash(hana::false_c), hana::type_c )); } }