/* Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #include #if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE) #include #include template struct range { T* data() { return 0; } const T* data() const { return 0; } std::size_t size() const { return 0; } }; struct base { }; struct derived : base { }; void test_default() { BOOST_TEST_TRAIT_TRUE((std::is_default_constructible< boost::span >)); BOOST_TEST_TRAIT_TRUE((std::is_default_constructible< boost::span >)); BOOST_TEST_TRAIT_FALSE((std::is_default_constructible< boost::span >)); } void test_data_size() { BOOST_TEST_TRAIT_TRUE((std::is_constructible, int*, std::size_t>)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, int*, std::size_t>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, int, std::size_t>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, const int*, std::size_t>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, derived*, std::size_t>)); } void test_first_last() { BOOST_TEST_TRAIT_TRUE((std::is_constructible, int*, int*>)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, int*, const int*>)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, int*, int*>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, int, int*>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, const int*, int*>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, derived*, derived*>)); } void test_array() { BOOST_TEST_TRAIT_TRUE((std::is_constructible, int(&)[4]>)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, int(&)[4]>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, int(&)[4]>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, int(&)[2]>)); } void test_std_array() { BOOST_TEST_TRAIT_TRUE((std::is_constructible, std::array&>)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, std::array&>)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, std::array&>)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, std::array&>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, std::array&>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, std::array&>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, std::array&>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, std::array&>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, std::array&>)); } void test_const_std_array() { BOOST_TEST_TRAIT_TRUE((std::is_constructible, const std::array >)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, const std::array >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, const std::array >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, const std::array >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, const std::array >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, const std::array >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, const std::array >)); } void test_range() { BOOST_TEST_TRAIT_TRUE((std::is_constructible, range&>)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, range&>)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, range >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, int*>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, range >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, const range&>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, range&>)); } void test_span() { BOOST_TEST_TRAIT_TRUE((std::is_constructible, boost::span >)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, boost::span >)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, boost::span >)); BOOST_TEST_TRAIT_TRUE((std::is_constructible, boost::span >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, boost::span >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, boost::span >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, boost::span >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, boost::span >)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, boost::span >)); } void test_copy() { BOOST_TEST_TRAIT_TRUE((std::is_copy_constructible< boost::span >)); BOOST_TEST_TRAIT_TRUE((std::is_copy_constructible< boost::span >)); } void test_assign() { BOOST_TEST_TRAIT_TRUE((std::is_copy_assignable< boost::span >)); BOOST_TEST_TRAIT_TRUE((std::is_copy_assignable< boost::span >)); } int main() { test_default(); test_data_size(); test_first_last(); test_array(); test_std_array(); test_const_std_array(); test_range(); test_span(); test_copy(); test_assign(); return boost::report_errors(); } #else int main() { return 0; } #endif