forked from boostorg/unordered
Refactor transparent type traits into their own header so they can be shared with FOA impl
This commit is contained in:
@ -47,6 +47,7 @@
|
|||||||
#include <boost/type_traits/make_void.hpp>
|
#include <boost/type_traits/make_void.hpp>
|
||||||
#include <boost/type_traits/remove_const.hpp>
|
#include <boost/type_traits/remove_const.hpp>
|
||||||
#include <boost/unordered/detail/fca.hpp>
|
#include <boost/unordered/detail/fca.hpp>
|
||||||
|
#include <boost/unordered/detail/type_traits.hpp>
|
||||||
#include <boost/unordered/detail/fwd.hpp>
|
#include <boost/unordered/detail/fwd.hpp>
|
||||||
#include <boost/utility/addressof.hpp>
|
#include <boost/utility/addressof.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
@ -618,39 +619,6 @@ namespace boost {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Type checkers used for the transparent member functions added by C++20 and up
|
|
||||||
|
|
||||||
template <class, class = void> struct is_transparent : public false_type
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct is_transparent<T,
|
|
||||||
typename boost::make_void<typename T::is_transparent>::type>
|
|
||||||
: public true_type
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class, class A, class B> struct are_transparent
|
|
||||||
{
|
|
||||||
static bool const value =
|
|
||||||
is_transparent<A>::value && is_transparent<B>::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class Key, class UnorderedMap> struct transparent_non_iterable
|
|
||||||
{
|
|
||||||
typedef typename UnorderedMap::hasher hash;
|
|
||||||
typedef typename UnorderedMap::key_equal key_equal;
|
|
||||||
typedef typename UnorderedMap::iterator iterator;
|
|
||||||
typedef typename UnorderedMap::const_iterator const_iterator;
|
|
||||||
|
|
||||||
static bool const value =
|
|
||||||
are_transparent<Key, hash, key_equal>::value &&
|
|
||||||
!boost::is_convertible<Key, iterator>::value &&
|
|
||||||
!boost::is_convertible<Key, const_iterator>::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Explicitly call a destructor
|
// Explicitly call a destructor
|
||||||
|
|
||||||
|
59
include/boost/unordered/detail/type_traits.hpp
Normal file
59
include/boost/unordered/detail/type_traits.hpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright (C) 2022 Christian Mazakas
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#ifndef BOOST_UNORDERED_DETAIL_TYPE_TRAITS_HPP
|
||||||
|
#define BOOST_UNORDERED_DETAIL_TYPE_TRAITS_HPP
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <boost/type_traits/integral_constant.hpp>
|
||||||
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
|
#include <boost/type_traits/make_void.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace unordered {
|
||||||
|
namespace detail {
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Type checkers used for the transparent member functions added by C++20
|
||||||
|
// and up
|
||||||
|
|
||||||
|
template <class, class = void>
|
||||||
|
struct is_transparent : public boost::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct is_transparent<T,
|
||||||
|
typename boost::make_void<typename T::is_transparent>::type>
|
||||||
|
: public boost::true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class, class A, class B> struct are_transparent
|
||||||
|
{
|
||||||
|
static bool const value =
|
||||||
|
is_transparent<A>::value && is_transparent<B>::value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Key, class UnorderedMap> struct transparent_non_iterable
|
||||||
|
{
|
||||||
|
typedef typename UnorderedMap::hasher hash;
|
||||||
|
typedef typename UnorderedMap::key_equal key_equal;
|
||||||
|
typedef typename UnorderedMap::iterator iterator;
|
||||||
|
typedef typename UnorderedMap::const_iterator const_iterator;
|
||||||
|
|
||||||
|
static bool const value =
|
||||||
|
are_transparent<Key, hash, key_equal>::value &&
|
||||||
|
!boost::is_convertible<Key, iterator>::value &&
|
||||||
|
!boost::is_convertible<Key, const_iterator>::value;
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
} // namespace unordered
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // BOOST_UNORDERED_DETAIL_TYPE_TRAITS_HPP
|
Reference in New Issue
Block a user