-
Notifications
You must be signed in to change notification settings - Fork 50
/
type_traits.hpp
69 lines (56 loc) · 1.51 KB
/
type_traits.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
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// 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)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_GRAMMAR_TYPE_TRAITS_HPP
#define BOOST_URL_GRAMMAR_TYPE_TRAITS_HPP
#include <boost/url/detail/config.hpp>
#include <boost/url/error_types.hpp>
#include <type_traits>
namespace boost {
namespace urls {
namespace grammar {
namespace see_below
{
template<class T, class = void>
struct is_rule : std::false_type {};
template<class T>
struct is_rule<T, void_t<decltype(
std::declval<system::result<typename T::value_type>&>() =
std::declval<T const&>().parse(
std::declval<char const*&>(),
std::declval<char const*>())
)>> : std::is_nothrow_copy_constructible<T>
{
};
}
/** Determine if T meets the requirements of Rule
This is an alias for `std::true_type` if
`T` meets the requirements, otherwise it
is an alias for `std::false_type`.
@par Example
@code
struct U
{
struct value_type;
auto
parse(
char const*& it,
char const* end) const ->
system::result<value_type>
};
static_assert( is_rule<U>::value, "Requirements not met" );
@endcode
@see
@ref parse.
*/
template<class T>
using is_rule = BOOST_URL_SEE_BELOW(see_below::is_rule<T>);
} // grammar
} // urls
} // boost
#endif