From d1b2640dffcd0dbae14f3f5d3a4b4954ad84923f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Sep 2022 19:37:15 +0300 Subject: [PATCH] Move type classification traits from namespace hash_detail to namespace container_hash --- .../detail/is_contiguous_range.hpp | 11 +++++--- .../boost/container_hash/detail/is_range.hpp | 26 +++++++++++++++---- .../detail/is_unordered_range.hpp | 9 +++++-- include/boost/container_hash/hash.hpp | 14 +++++----- test/detail_is_contiguous_range_test.cpp | 2 +- test/detail_is_range_test.cpp | 2 +- test/detail_is_range_test2.cpp | 2 +- test/detail_is_unordered_range_test.cpp | 2 +- 8 files changed, 47 insertions(+), 21 deletions(-) diff --git a/include/boost/container_hash/detail/is_contiguous_range.hpp b/include/boost/container_hash/detail/is_contiguous_range.hpp index 74dc8f8..d21bdb1 100644 --- a/include/boost/container_hash/detail/is_contiguous_range.hpp +++ b/include/boost/container_hash/detail/is_contiguous_range.hpp @@ -28,11 +28,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_( ... ); +} // namespace hash_detail + +namespace container_hash +{ + template struct is_contiguous_range: decltype( hash_detail::is_contiguous_range_( 0 ) ) { }; -} // namespace hash_detail +} // namespace container_hash } // namespace boost #else // !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) @@ -46,7 +51,7 @@ template struct is_contiguous_range: decltype( hash_detail::is_contiguo namespace boost { -namespace hash_detail +namespace container_hash { template struct is_contiguous_range: false_type @@ -73,7 +78,7 @@ template struct is_contiguous_range< std::array co #endif -} // namespace hash_detail +} // namespace container_hash } // namespace boost #endif // !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) diff --git a/include/boost/container_hash/detail/is_range.hpp b/include/boost/container_hash/detail/is_range.hpp index 983d9f1..0ded066 100644 --- a/include/boost/container_hash/detail/is_range.hpp +++ b/include/boost/container_hash/detail/is_range.hpp @@ -16,11 +16,11 @@ namespace boost { +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC, < 40700) + namespace hash_detail { -#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC, < 40700) - template integral_constant< bool, !is_same::type, typename std::iterator_traits::value_type>::value > is_range_check( It first, It last ); @@ -28,12 +28,22 @@ template template decltype( is_range_check( declval().begin(), declval().end() ) ) is_range_( int ); template false_type is_range_( ... ); -template struct is_range: decltype( is_range_( 0 ) ) +} // namespace hash_detail + +namespace container_hash +{ + +template struct is_range: decltype( hash_detail::is_range_( 0 ) ) { }; +} // namespace container_hash + #else +namespace hash_detail +{ + template struct is_range_: false_type { }; @@ -45,13 +55,19 @@ template struct is_range_< T, integral_constant< bool, { }; -template struct is_range: is_range_ +} // namespace hash_detail + +namespace container_hash +{ + +template struct is_range: hash_detail::is_range_ { }; +} // namespace container_hash + #endif // !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) -} // namespace hash_detail } // namespace boost #endif // #ifndef BOOST_HASH_DETAIL_IS_RANGE_HPP_INCLUDED diff --git a/include/boost/container_hash/detail/is_unordered_range.hpp b/include/boost/container_hash/detail/is_unordered_range.hpp index 218cffb..442e0c7 100644 --- a/include/boost/container_hash/detail/is_unordered_range.hpp +++ b/include/boost/container_hash/detail/is_unordered_range.hpp @@ -24,11 +24,16 @@ template struct has_hasher_< T, integral_constant< bool, { }; -template struct is_unordered_range: integral_constant< bool, is_range::value && has_hasher_::value > +} // namespace hash_detail + +namespace container_hash +{ + +template struct is_unordered_range: integral_constant< bool, is_range::value && hash_detail::has_hasher_::value > { }; -} // namespace hash_detail +} // namespace container_hash } // namespace boost #endif // #ifndef BOOST_HASH_DETAIL_IS_UNORDERED_RANGE_HPP_INCLUDED diff --git a/include/boost/container_hash/hash.hpp b/include/boost/container_hash/hash.hpp index 8d8df3d..8e06726 100644 --- a/include/boost/container_hash/hash.hpp +++ b/include/boost/container_hash/hash.hpp @@ -393,7 +393,7 @@ namespace boost // ranges (list, set, deque...) template - typename boost::enable_if_::value && !hash_detail::is_contiguous_range::value && !hash_detail::is_unordered_range::value, std::size_t>::type + typename boost::enable_if_::value && !container_hash::is_contiguous_range::value && !container_hash::is_unordered_range::value, std::size_t>::type hash_value( T const& v ) { return boost::hash_range( v.begin(), v.end() ); @@ -402,7 +402,7 @@ namespace boost // contiguous ranges (string, vector, array) template - typename boost::enable_if_::value, std::size_t>::type + typename boost::enable_if_::value, std::size_t>::type hash_value( T const& v ) { return boost::hash_range( v.data(), v.data() + v.size() ); @@ -411,7 +411,7 @@ namespace boost // unordered ranges (unordered_set, unordered_map) template - typename boost::enable_if_::value, std::size_t>::type + typename boost::enable_if_::value, std::size_t>::type hash_value( T const& v ) { return boost::hash_unordered_range( v.begin(), v.end() ); @@ -422,7 +422,7 @@ namespace boost // resolve ambiguity with unconstrained stdext::hash_value in :-/ template class L, class... T> - typename boost::enable_if_>::value && !hash_detail::is_contiguous_range>::value && !hash_detail::is_unordered_range>::value, std::size_t>::type + typename boost::enable_if_>::value && !container_hash::is_contiguous_range>::value && !container_hash::is_unordered_range>::value, std::size_t>::type hash_value( L const& v ) { return boost::hash_range( v.begin(), v.end() ); @@ -431,14 +431,14 @@ namespace boost // contiguous ranges (string, vector, array) template class L, class... T> - typename boost::enable_if_>::value, std::size_t>::type + typename boost::enable_if_>::value, std::size_t>::type hash_value( L const& v ) { return boost::hash_range( v.data(), v.data() + v.size() ); } template class L, class T, std::size_t N> - typename boost::enable_if_>::value, std::size_t>::type + typename boost::enable_if_>::value, std::size_t>::type hash_value( L const& v ) { return boost::hash_range( v.data(), v.data() + v.size() ); @@ -447,7 +447,7 @@ namespace boost // unordered ranges (unordered_set, unordered_map) template class L, class... T> - typename boost::enable_if_>::value, std::size_t>::type + typename boost::enable_if_>::value, std::size_t>::type hash_value( L const& v ) { return boost::hash_unordered_range( v.begin(), v.end() ); diff --git a/test/detail_is_contiguous_range_test.cpp b/test/detail_is_contiguous_range_test.cpp index 99efba0..3cee33e 100644 --- a/test/detail_is_contiguous_range_test.cpp +++ b/test/detail_is_contiguous_range_test.cpp @@ -30,7 +30,7 @@ struct X int main() { - using boost::hash_detail::is_contiguous_range; + using boost::container_hash::is_contiguous_range; BOOST_TEST_TRAIT_FALSE((is_contiguous_range)); BOOST_TEST_TRAIT_FALSE((is_contiguous_range)); diff --git a/test/detail_is_range_test.cpp b/test/detail_is_range_test.cpp index d45987c..e96980e 100644 --- a/test/detail_is_range_test.cpp +++ b/test/detail_is_range_test.cpp @@ -30,7 +30,7 @@ struct X int main() { - using boost::hash_detail::is_range; + using boost::container_hash::is_range; BOOST_TEST_TRAIT_FALSE((is_range)); BOOST_TEST_TRAIT_FALSE((is_range)); diff --git a/test/detail_is_range_test2.cpp b/test/detail_is_range_test2.cpp index b1cf8b2..864b645 100644 --- a/test/detail_is_range_test2.cpp +++ b/test/detail_is_range_test2.cpp @@ -21,7 +21,7 @@ int main() { - using boost::hash_detail::is_range; + using boost::container_hash::is_range; BOOST_TEST_TRAIT_FALSE((is_range< boost::filesystem::path >)); BOOST_TEST_TRAIT_FALSE((is_range< boost::filesystem::path const >)); diff --git a/test/detail_is_unordered_range_test.cpp b/test/detail_is_unordered_range_test.cpp index 698edcb..a4b85ca 100644 --- a/test/detail_is_unordered_range_test.cpp +++ b/test/detail_is_unordered_range_test.cpp @@ -30,7 +30,7 @@ struct X int main() { - using boost::hash_detail::is_unordered_range; + using boost::container_hash::is_unordered_range; BOOST_TEST_TRAIT_FALSE((is_unordered_range)); BOOST_TEST_TRAIT_FALSE((is_unordered_range));