Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
Cpp17.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19
20#pragma once
21
22#include <type_traits>
23
25
31namespace experimental {
32 // 3.3.3, Logical operator traits
33 template <class...> using void_t = void;
34
35 // 3.3.4, Detection idiom
36 template <class...> using void_t = void;
37
38 struct nonesuch {
39 nonesuch() = delete;
40 ~nonesuch() = delete;
41 nonesuch (nonesuch const&) = delete;
42 void operator=(nonesuch const&) = delete;
43 };
44
45 template <class _Default, class _AlwaysVoid, template <class...> class _Op, class... _Args>
46 struct _DETECTOR {
47 using value_t = std::false_type;
48 using type = _Default;
49 };
50
51 template <class _Default, template <class...> class _Op, class... _Args>
52 struct _DETECTOR<_Default, void_t<_Op<_Args...>>, _Op, _Args...> {
53 using value_t = std::true_type;
54 using type = _Op<_Args...>;
55 };
56
57
58 template <template<class...> class _Op, class... _Args>
59 using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t;
60 template <template<class...> class _Op, class... _Args>
61 using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type;
62 template <template<class...> class _Op, class... _Args>
63 constexpr bool is_detected_v = is_detected<_Op, _Args...>::value;
64
65 template <class Default, template<class...> class _Op, class... _Args>
66 using detected_or = _DETECTOR<Default, void, _Op, _Args...>;
67 template <class Default, template<class...> class _Op, class... _Args>
68 using detected_or_t = typename detected_or<Default, _Op, _Args...>::type;
69
70 template <class Expected, template<class...> class _Op, class... _Args>
71 using is_detected_exact = std::is_same<Expected, detected_t<_Op, _Args...>>;
72 template <class Expected, template<class...> class _Op, class... _Args>
73 constexpr bool is_detected_exact_v = is_detected_exact<Expected, _Op, _Args...>::value;
74
75 template <class To, template<class...> class _Op, class... _Args>
76 using is_detected_convertible = std::is_convertible<detected_t<_Op, _Args...>, To>;
77 template <class To, template<class...> class _Op, class... _Args>
78 constexpr bool is_detected_convertible_v = is_detected_convertible<To, _Op, _Args...>::value;
79
80
81}}
The code here is copied from <experimental/type_traits> because it is not implemented with Visual stu...
Definition Cpp17.h:31
constexpr bool is_detected_v
Definition Cpp17.h:63
std::is_convertible< detected_t< _Op, _Args... >, To > is_detected_convertible
Definition Cpp17.h:76
std::is_same< Expected, detected_t< _Op, _Args... > > is_detected_exact
Definition Cpp17.h:71
typename _DETECTOR< nonesuch, void, _Op, _Args... >::type detected_t
Definition Cpp17.h:61
typename _DETECTOR< nonesuch, void, _Op, _Args... >::value_t is_detected
Definition Cpp17.h:59
typename detected_or< Default, _Op, _Args... >::type detected_or_t
Definition Cpp17.h:68
void void_t
Definition Cpp17.h:33
constexpr bool is_detected_convertible_v
Definition Cpp17.h:78
_DETECTOR< Default, void, _Op, _Args... > detected_or
Definition Cpp17.h:66
constexpr bool is_detected_exact_v
Definition Cpp17.h:73
Definition Cpp17.h:24
std::false_type value_t
Definition Cpp17.h:47
void operator=(nonesuch const &)=delete