diff --git a/include/boost/container_hash/detail/is_unordered_range.hpp b/include/boost/container_hash/detail/is_unordered_range.hpp new file mode 100644 index 0000000..218cffb --- /dev/null +++ b/include/boost/container_hash/detail/is_unordered_range.hpp @@ -0,0 +1,34 @@ +// Copyright 2017 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_HASH_DETAIL_IS_UNORDERED_RANGE_HPP_INCLUDED +#define BOOST_HASH_DETAIL_IS_UNORDERED_RANGE_HPP_INCLUDED + +#include +#include +#include + +namespace boost +{ +namespace hash_detail +{ + +template struct has_hasher_: false_type +{ +}; + +template struct has_hasher_< T, integral_constant< bool, + is_same::value + > >: true_type +{ +}; + +template struct is_unordered_range: integral_constant< bool, is_range::value && has_hasher_::value > +{ +}; + +} // namespace hash_detail +} // namespace boost + +#endif // #ifndef BOOST_HASH_DETAIL_IS_UNORDERED_RANGE_HPP_INCLUDED diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c6d2ac8..e960607 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -88,3 +88,4 @@ build-project ../examples ; run detail_is_range_test.cpp ; run detail_is_contiguous_range_test.cpp ; +run detail_is_unordered_range_test.cpp ; diff --git a/test/detail_is_unordered_range_test.cpp b/test/detail_is_unordered_range_test.cpp new file mode 100644 index 0000000..698edcb --- /dev/null +++ b/test/detail_is_unordered_range_test.cpp @@ -0,0 +1,98 @@ +// Copyright 2017 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) +# include +#endif +#if !defined(BOOST_NO_CXX11_HDR_FORWARD_LIST) +# include +#endif +#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET) +# include +#endif +#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_MAP) +# include +#endif + +struct X +{ +}; + +int main() +{ + using boost::hash_detail::is_unordered_range; + + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::vector >)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::vector const >)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::deque >)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::deque const >)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::set >)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::set const >)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::multiset >)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::multiset const >)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::map >)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::map const >)); + + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::multimap >)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::multimap const >)); + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::array >)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::array const >)); +#endif + +#if !defined(BOOST_NO_CXX11_HDR_FORWARD_LIST) + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::forward_list >)); + BOOST_TEST_TRAIT_FALSE((is_unordered_range< std::forward_list const >)); +#endif + +#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET) + BOOST_TEST_TRAIT_TRUE((is_unordered_range< std::unordered_set >)); + BOOST_TEST_TRAIT_TRUE((is_unordered_range< std::unordered_set const >)); + + BOOST_TEST_TRAIT_TRUE((is_unordered_range< std::unordered_multiset >)); + BOOST_TEST_TRAIT_TRUE((is_unordered_range< std::unordered_multiset const >)); +#endif + +#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_MAP) + BOOST_TEST_TRAIT_TRUE((is_unordered_range< std::unordered_map >)); + BOOST_TEST_TRAIT_TRUE((is_unordered_range< std::unordered_map const >)); + + BOOST_TEST_TRAIT_TRUE((is_unordered_range< std::unordered_multimap >)); + BOOST_TEST_TRAIT_TRUE((is_unordered_range< std::unordered_multimap const >)); +#endif + + return boost::report_errors(); +}