2015-07-16 18:12:06 +03:00
|
|
|
#ifndef BOOST_MP11_FUNCTION_HPP_INCLUDED
|
|
|
|
|
#define BOOST_MP11_FUNCTION_HPP_INCLUDED
|
|
|
|
|
|
2017-03-16 17:49:57 +02:00
|
|
|
// Copyright 2015-2017 Peter Dimov.
|
2015-07-16 18:12:06 +03:00
|
|
|
//
|
|
|
|
|
// 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
|
|
|
|
|
|
2016-11-16 04:19:37 +02:00
|
|
|
#include <boost/mp11/integral.hpp>
|
2016-11-16 21:24:13 +02:00
|
|
|
#include <boost/mp11/utility.hpp>
|
|
|
|
|
#include <boost/mp11/detail/mp_list.hpp>
|
|
|
|
|
#include <boost/mp11/detail/mp_count.hpp>
|
2017-05-24 01:52:11 +03:00
|
|
|
#include <boost/mp11/detail/mp_plus.hpp>
|
2017-04-01 20:01:51 +03:00
|
|
|
#include <type_traits>
|
2016-11-16 04:19:37 +02:00
|
|
|
|
2015-07-16 18:12:06 +03:00
|
|
|
namespace boost
|
|
|
|
|
{
|
2017-03-15 21:23:15 +02:00
|
|
|
namespace mp11
|
|
|
|
|
{
|
2015-07-16 18:12:06 +03:00
|
|
|
|
2017-05-24 01:37:49 +03:00
|
|
|
// mp_void<T...>
|
|
|
|
|
namespace detail
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
template<class... T> struct mp_void_impl
|
|
|
|
|
{
|
|
|
|
|
using type = void;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
|
|
template<class... T> using mp_void = typename detail::mp_void_impl<T...>::type;
|
|
|
|
|
|
2017-05-24 04:27:36 +03:00
|
|
|
// mp_and<T...>
|
2017-05-24 01:37:49 +03:00
|
|
|
#if BOOST_WORKAROUND( BOOST_MSVC, < 1910 )
|
2016-11-16 21:24:13 +02:00
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
template<class... T> struct mp_and_impl;
|
|
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
2017-05-23 23:25:30 +03:00
|
|
|
template<class... T> using mp_and = mp_to_bool< typename detail::mp_and_impl<T...>::type >;
|
2016-11-16 21:24:13 +02:00
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
template<> struct mp_and_impl<>
|
|
|
|
|
{
|
|
|
|
|
using type = mp_true;
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-16 17:49:57 +02:00
|
|
|
template<class T> struct mp_and_impl<T>
|
|
|
|
|
{
|
|
|
|
|
using type = T;
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-16 21:24:13 +02:00
|
|
|
template<class T1, class... T> struct mp_and_impl<T1, T...>
|
|
|
|
|
{
|
2017-03-16 17:49:57 +02:00
|
|
|
using type = mp_eval_if< mp_not<T1>, T1, mp_and, T... >;
|
2016-11-16 21:24:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
2017-05-23 23:25:30 +03:00
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
template<class L, class E = void> struct mp_and_impl
|
|
|
|
|
{
|
|
|
|
|
using type = mp_false;
|
|
|
|
|
};
|
|
|
|
|
|
2017-05-24 01:37:49 +03:00
|
|
|
template<class... T> struct mp_and_impl< mp_list<T...>, mp_void<mp_if<T, void>...> >
|
2017-05-23 23:25:30 +03:00
|
|
|
{
|
|
|
|
|
using type = mp_true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
|
|
template<class... T> using mp_and = typename detail::mp_and_impl<mp_list<T...>>::type;
|
2017-05-24 04:27:36 +03:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// mp_all<T...>
|
2017-08-24 20:05:24 +03:00
|
|
|
#if BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) || BOOST_WORKAROUND( BOOST_GCC, < 70300 )
|
2017-05-24 04:27:36 +03:00
|
|
|
|
2017-05-31 07:57:02 +03:00
|
|
|
template<class... T> using mp_all = mp_bool< mp_count_if< mp_list<T...>, mp_not >::value == 0 >;
|
2017-05-24 04:27:36 +03:00
|
|
|
|
2017-05-24 05:59:15 +03:00
|
|
|
#elif defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS )
|
|
|
|
|
|
|
|
|
|
template<class... T> using mp_all = mp_bool<(static_cast<bool>(T::value) && ...)>;
|
|
|
|
|
|
2017-05-24 04:27:36 +03:00
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
template<class... T> using mp_all = mp_and<mp_to_bool<T>...>;
|
2017-05-23 23:25:30 +03:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-05-24 01:37:49 +03:00
|
|
|
// mp_or<T...>
|
2016-11-16 21:24:13 +02:00
|
|
|
namespace detail
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
template<class... T> struct mp_or_impl;
|
|
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
2017-05-23 23:25:30 +03:00
|
|
|
template<class... T> using mp_or = mp_to_bool< typename detail::mp_or_impl<T...>::type >;
|
2016-11-16 21:24:13 +02:00
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
template<> struct mp_or_impl<>
|
|
|
|
|
{
|
|
|
|
|
using type = mp_false;
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-16 17:49:57 +02:00
|
|
|
template<class T> struct mp_or_impl<T>
|
|
|
|
|
{
|
|
|
|
|
using type = T;
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-16 21:24:13 +02:00
|
|
|
template<class T1, class... T> struct mp_or_impl<T1, T...>
|
|
|
|
|
{
|
2017-03-16 17:49:57 +02:00
|
|
|
using type = mp_eval_if< T1, T1, mp_or, T... >;
|
2016-11-16 21:24:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace detail
|
2015-07-16 18:12:06 +03:00
|
|
|
|
2017-05-24 01:37:49 +03:00
|
|
|
// mp_any<T...>
|
2017-08-26 11:12:54 +03:00
|
|
|
#if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) && !BOOST_WORKAROUND( BOOST_GCC, < 70300 )
|
2017-05-24 05:59:15 +03:00
|
|
|
|
|
|
|
|
template<class... T> using mp_any = mp_bool<(static_cast<bool>(T::value) || ...)>;
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
2017-05-23 23:25:30 +03:00
|
|
|
template<class... T> using mp_any = mp_bool< mp_count_if< mp_list<T...>, mp_to_bool >::value != 0 >;
|
|
|
|
|
|
2017-05-24 05:59:15 +03:00
|
|
|
#endif
|
|
|
|
|
|
2017-04-01 20:01:51 +03:00
|
|
|
// mp_same<T...>
|
|
|
|
|
namespace detail
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
template<class... T> struct mp_same_impl;
|
|
|
|
|
|
|
|
|
|
template<> struct mp_same_impl<>
|
|
|
|
|
{
|
|
|
|
|
using type = mp_true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class T1, class... T> struct mp_same_impl<T1, T...>
|
|
|
|
|
{
|
|
|
|
|
using type = mp_all<std::is_same<T1, T>...>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
|
|
template<class... T> using mp_same = typename detail::mp_same_impl<T...>::type;
|
|
|
|
|
|
2017-03-15 21:23:15 +02:00
|
|
|
} // namespace mp11
|
2015-07-16 18:12:06 +03:00
|
|
|
} // namespace boost
|
|
|
|
|
|
|
|
|
|
#endif // #ifndef BOOST_MP11_FUNCTION_HPP_INCLUDED
|