From 79fff9e1ea2c1a809d8a0a1d1950c9b6b40ac4c9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 18 Sep 2022 14:26:30 +0300 Subject: [PATCH] Add is_contiguous_range_test2 --- .../container_hash/is_contiguous_range.hpp | 7 ++- test/Jamfile.v2 | 1 + test/is_contiguous_range_test2.cpp | 63 +++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 test/is_contiguous_range_test2.cpp diff --git a/include/boost/container_hash/is_contiguous_range.hpp b/include/boost/container_hash/is_contiguous_range.hpp index 7cbf074..08d3d59 100644 --- a/include/boost/container_hash/is_contiguous_range.hpp +++ b/include/boost/container_hash/is_contiguous_range.hpp @@ -5,6 +5,7 @@ #ifndef BOOST_HASH_IS_CONTIGUOUS_RANGE_HPP_INCLUDED #define BOOST_HASH_IS_CONTIGUOUS_RANGE_HPP_INCLUDED +#include #include #include #include @@ -28,12 +29,16 @@ template template decltype( is_contiguous_range_check( declval().begin(), declval().end(), declval().data(), declval().data() + declval().size(), declval().size() ) ) is_contiguous_range_( int ); template false_type is_contiguous_range_( ... ); +template struct is_contiguous_range: decltype( hash_detail::is_contiguous_range_( 0 ) ) +{ +}; + } // namespace hash_detail namespace container_hash { -template struct is_contiguous_range: decltype( hash_detail::is_contiguous_range_( 0 ) ) +template struct is_contiguous_range: integral_constant< bool, is_range::value && hash_detail::is_contiguous_range::value > { }; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 814200a..7a47734 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -99,3 +99,4 @@ run hash_unordered_set_test.cpp ; run hash_unordered_map_test.cpp ; run is_range_test3.cpp ; +run is_contiguous_range_test2.cpp ; diff --git a/test/is_contiguous_range_test2.cpp b/test/is_contiguous_range_test2.cpp new file mode 100644 index 0000000..c37980b --- /dev/null +++ b/test/is_contiguous_range_test2.cpp @@ -0,0 +1,63 @@ +// Copyright 2022 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +struct X1 +{ + char const* begin() const; + char const* end() const; + char const* data() const; + std::size_t size() const; +}; + +struct X2 +{ + char const* begin() const; + char const* end() const; + char const* data() const; + std::size_t size() const; +}; + +struct X3 +{ + char const* begin() const; + char const* end() const; + char const* data() const; + std::size_t size() const; +}; + +namespace boost +{ +namespace container_hash +{ + +template struct is_contiguous_range; +template<> struct is_contiguous_range: boost::false_type {}; + +template struct is_range; +template<> struct is_range: boost::false_type {}; + +} // namespace container_hash +} // namespace boost + +#include +#include + +int main() +{ + using boost::container_hash::is_contiguous_range; + +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC, < 40700) + + BOOST_TEST_TRAIT_TRUE((is_contiguous_range)); + +#endif + + BOOST_TEST_TRAIT_FALSE((is_contiguous_range)); + BOOST_TEST_TRAIT_FALSE((is_contiguous_range)); + + return boost::report_errors(); +}