Edit: /usr/include/boost/hana/type.hpp (10082B)
/*!
@file
Defines `boost::hana::type` and related utilities.
@copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_HANA_TYPE_HPP
#define BOOST_HANA_TYPE_HPP
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
BOOST_HANA_NAMESPACE_BEGIN
//////////////////////////////////////////////////////////////////////////
// basic_type
//////////////////////////////////////////////////////////////////////////
//! @cond
template
struct basic_type : detail::operators::adl> {
using hana_tag = type_tag;
using type = T;
constexpr auto operator+() const { return *this; }
};
//! @endcond
//////////////////////////////////////////////////////////////////////////
// type
//////////////////////////////////////////////////////////////////////////
template
struct type_impl {
struct _ : basic_type { };
};
//////////////////////////////////////////////////////////////////////////
// decltype_
//////////////////////////////////////////////////////////////////////////
namespace detail {
template
struct decltype_t {
using type = typename std::remove_reference::type;
};
template
struct decltype_t::type> {
using type = typename std::remove_reference::type::type;
};
}
//! @cond
template
constexpr auto decltype_t::operator()(T&&) const
{ return hana::type_c::type>; }
//! @endcond
//////////////////////////////////////////////////////////////////////////
// typeid_
//////////////////////////////////////////////////////////////////////////
namespace detail {
template
struct typeid_t {
using type = typename std::remove_cv<
typename std::remove_reference::type
>::type;
};
template
struct typeid_t::type> {
using type = typename std::remove_reference::type::type;
};
}
//! @cond
template
constexpr auto typeid_t::operator()(T&&) const
{ return hana::type_c::type>; }
//! @endcond
//////////////////////////////////////////////////////////////////////////
// make
//////////////////////////////////////////////////////////////////////////
template <>
struct make_impl {
template
static constexpr auto apply(T&& t)
{ return hana::typeid_(static_cast(t)); }
};
//////////////////////////////////////////////////////////////////////////
// sizeof_
//////////////////////////////////////////////////////////////////////////
//! @cond
template
constexpr auto sizeof_t::operator()(T&&) const
{ return hana::size_c::type)>; }
//! @endcond
//////////////////////////////////////////////////////////////////////////
// alignof_
//////////////////////////////////////////////////////////////////////////
//! @cond
template
constexpr auto alignof_t::operator()(T&&) const
{ return hana::size_c::type)>; }
//! @endcond
//////////////////////////////////////////////////////////////////////////
// is_valid
//////////////////////////////////////////////////////////////////////////
namespace type_detail {
template ()(std::declval()...)
)>
constexpr auto is_valid_impl(int) { return hana::true_c; }
template
constexpr auto is_valid_impl(...) { return hana::false_c; }
template
struct is_valid_fun {
template
constexpr auto operator()(Args&& ...) const
{ return is_valid_impl(int{}); }
};
}
//! @cond
template
constexpr auto is_valid_t::operator()(F&&) const
{ return type_detail::is_valid_fun{}; }
template
constexpr auto is_valid_t::operator()(F&&, Args&& ...) const
{ return type_detail::is_valid_impl(int{}); }
//! @endcond
//////////////////////////////////////////////////////////////////////////
// template_
//////////////////////////////////////////////////////////////////////////
// Note: We have to use the very complicated trick below instead of just
// mentionning `F` in a SFINAE-able context because of CWG 1430
// (http://www.open-std.org/Jtc1/sc22/wg21/docs/cwg_active.html#1430).
namespace template_detail {
template struct args;
template using always_void = void;
template class F, typename Args, typename = void>
struct specialization_is_valid
: std::false_type
{ };
template class F, typename ...T>
struct specialization_is_valid, always_void>>
: std::true_type
{ };
} // end namespace detail
template class F>
struct template_t {
template
struct apply {
using type = F;
};
template >::value
>>
constexpr auto operator()(T const& ...) const
{ return hana::type>{}; }
};
//////////////////////////////////////////////////////////////////////////
// metafunction
//////////////////////////////////////////////////////////////////////////
template class F>
struct metafunction_t {
template
using apply = F;
template
constexpr hana::type::type>
operator()(T const& ...) const { return {}; }
};
//////////////////////////////////////////////////////////////////////////
// metafunction_class
//////////////////////////////////////////////////////////////////////////
namespace detail {
template
struct always_first { using type = F; };
}
template
struct metafunction_class_t {
template
using apply = typename detail::always_first::type::template apply;
template
constexpr hana::type::type::template apply::type>
operator()(T const& ...) const { return {}; }
};
//////////////////////////////////////////////////////////////////////////
// Metafunction
//////////////////////////////////////////////////////////////////////////
template class F>
struct Metafunction> {
static constexpr bool value = true;
};
template class F>
struct Metafunction> {
static constexpr bool value = true;
};
template
struct Metafunction> {
static constexpr bool value = true;
};
//////////////////////////////////////////////////////////////////////////
// integral
//////////////////////////////////////////////////////////////////////////
template
struct integral_t {
template ::type::template apply::type
>
constexpr Result operator()(T const& ...) const {
return Result{};
}
};
//////////////////////////////////////////////////////////////////////////
// Operators
//////////////////////////////////////////////////////////////////////////
namespace detail {
template <>
struct comparable_operators {
static constexpr bool value = true;
};
}
//////////////////////////////////////////////////////////////////////////
// Comparable
//////////////////////////////////////////////////////////////////////////
template <>
struct equal_impl {
template
static constexpr auto apply(basic_type const&, basic_type const&)
{ return hana::false_c; }
template
static constexpr auto apply(basic_type const&, basic_type const&)
{ return hana::true_c; }
};
//////////////////////////////////////////////////////////////////////////
// Hashable
//////////////////////////////////////////////////////////////////////////
template <>
struct hash_impl {
template
static constexpr T apply(T const& t)
{ return t; }
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_TYPE_HPP