forked from BoostGSoC19/astronomy
/
is_base_template_of.hpp
57 lines (37 loc) · 1.83 KB
/
is_base_template_of.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*=============================================================================
Copyright 2018-2020 Pranam Lashkari < lpranam - plashkari628@gmail.com >
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef BOOST_ASTRONOMY_DETAIL_IS_BASE_TEMPLATE_OF_HPP
#define BOOST_ASTRONOMY_DETAIL_IS_BASE_TEMPLATE_OF_HPP
#include <cstddef>
#include <type_traits>
namespace boost { namespace astronomy { namespace detail {
///@cond INTERNAL
// structure to provide support like std::is_base_of for template base classes
template <template <std::size_t, typename...> class Base, typename Derived>
struct base_template
{
//using U = typename std::remove_cv<Derived>::type;
template <std::size_t T, typename... Args>
static constexpr std::true_type test(const Base<T, Args...>*);
static constexpr std::false_type test(...);
using type = decltype(test(std::declval<Derived*>()));
};
template <template <std::size_t, typename...> class Base, typename Derived>
using is_base_template_of = typename base_template<Base, Derived>::type;
// structure to provide support like std::is_base_of for template base classes
template <template <typename...> class Base, typename Derived>
struct base_frame_template
{
template <typename... Args>
static constexpr std::true_type test(const Base<Args...> *);
static constexpr std::false_type test(...);
using type = decltype(test(std::declval<Derived*>()));
};
template <template <typename...> class Base, typename Derived>
using is_base_frame_of = typename base_frame_template<Base, Derived>::type;
///@endcond
}}} //namespace boost::astronomy::detail
#endif // !BOOST_ASTRONOMY_DETAIL_IS_BASE_TEMPLATE_OF_HPP