forked from boostorg/unordered
Add SFINAE helpers to type_traits.hpp
This commit is contained in:
@ -182,18 +182,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
|
||||||
|
|
||||||
#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES)
|
|
||||||
#if BOOST_COMP_CLANG && __cplusplus >= 201703
|
|
||||||
#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES)
|
|
||||||
#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace unordered {
|
namespace unordered {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@ -14,6 +14,25 @@
|
|||||||
#include <boost/type_traits/integral_constant.hpp>
|
#include <boost/type_traits/integral_constant.hpp>
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
#include <boost/type_traits/make_void.hpp>
|
#include <boost/type_traits/make_void.hpp>
|
||||||
|
#include <boost/type_traits/type_identity.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX17_DEDUCTION_GUIDES)
|
||||||
|
#include <boost/type_traits/enable_if.hpp>
|
||||||
|
#include <boost/type_traits/is_integral.hpp>
|
||||||
|
#include <boost/type_traits/remove_const.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||||
|
|
||||||
|
#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES)
|
||||||
|
#if !defined(BOOST_NO_CXX17_DEDUCTION_GUIDES)
|
||||||
|
#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES)
|
||||||
|
#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 0
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace unordered {
|
namespace unordered {
|
||||||
@ -52,6 +71,37 @@ namespace boost {
|
|||||||
!boost::is_convertible<Key, iterator>::value &&
|
!boost::is_convertible<Key, iterator>::value &&
|
||||||
!boost::is_convertible<Key, const_iterator>::value;
|
!boost::is_convertible<Key, const_iterator>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||||
|
// https://eel.is/c++draft/container.requirements#container.alloc.reqmts-34
|
||||||
|
// https://eel.is/c++draft/container.requirements#unord.req.general-243
|
||||||
|
|
||||||
|
template <class InputIterator>
|
||||||
|
constexpr bool const is_input_iterator_v =
|
||||||
|
!boost::is_integral<InputIterator>::value;
|
||||||
|
|
||||||
|
template <class A, class = void> struct is_allocator
|
||||||
|
{
|
||||||
|
constexpr static bool const value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class A>
|
||||||
|
struct is_allocator<A,
|
||||||
|
boost::void_t<typename A::value_type,
|
||||||
|
decltype(std::declval<A&>().allocate(std::size_t{}))> >
|
||||||
|
{
|
||||||
|
constexpr static bool const value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class A>
|
||||||
|
constexpr bool const is_allocator_v = is_allocator<A>::value;
|
||||||
|
|
||||||
|
template <class H>
|
||||||
|
constexpr bool const is_hash_v =
|
||||||
|
!boost::is_integral<H>::value && !is_allocator_v<H>;
|
||||||
|
|
||||||
|
template <class P> constexpr bool const is_pred_v = !is_allocator_v<P>;
|
||||||
|
#endif
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace unordered
|
} // namespace unordered
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
Reference in New Issue
Block a user