WPILibC++ 2024.3.2
detected.h
Go to the documentation of this file.
1// __ _____ _____ _____
2// __| | __| | | | JSON for Modern C++
3// | | |__ | | | | | | version 3.11.2
4// |_____|_____|_____|_|___| https://github.com/nlohmann/json
5//
6// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
7// SPDX-License-Identifier: MIT
8
9#pragma once
10
11#include <type_traits>
12
14
16namespace detail
17{
18
19// https://en.cppreference.com/w/cpp/experimental/is_detected
21{
22 nonesuch() = delete;
23 ~nonesuch() = delete;
24 nonesuch(nonesuch const&) = delete;
25 nonesuch(nonesuch const&&) = delete;
26 void operator=(nonesuch const&) = delete;
27 void operator=(nonesuch&&) = delete;
28};
29
30template<class Default,
31 class AlwaysVoid,
32 template<class...> class Op,
33 class... Args>
35{
36 using value_t = std::false_type;
37 using type = Default;
38};
39
40template<class Default, template<class...> class Op, class... Args>
41struct detector<Default, void_t<Op<Args...>>, Op, Args...>
42{
43 using value_t = std::true_type;
44 using type = Op<Args...>;
45};
46
47template<template<class...> class Op, class... Args>
48using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t;
49
50template<template<class...> class Op, class... Args>
51struct is_detected_lazy : is_detected<Op, Args...> { };
52
53template<template<class...> class Op, class... Args>
54using detected_t = typename detector<nonesuch, void, Op, Args...>::type;
55
56template<class Default, template<class...> class Op, class... Args>
57using detected_or = detector<Default, void, Op, Args...>;
58
59template<class Default, template<class...> class Op, class... Args>
60using detected_or_t = typename detected_or<Default, Op, Args...>::type;
61
62template<class Expected, template<class...> class Op, class... Args>
63using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
64
65template<class To, template<class...> class Op, class... Args>
67 std::is_convertible<detected_t<Op, Args...>, To>;
68
69} // namespace detail
#define WPI_JSON_NAMESPACE_END
Definition: abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition: abi_macros.h:53
detail namespace with internal helper functions
Definition: xchar.h:20
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: detected.h:63
void void_t
Definition: core.h:1510
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition: detected.h:67
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition: detected.h:60
value_t
the JSON type enumeration
Definition: value_t.h:54
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition: detected.h:54
type
Definition: core.h:556
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition: detected.h:48
Definition: detected.h:35
std::false_type value_t
Definition: detected.h:36
Default type
Definition: detected.h:37
Definition: detected.h:51
Definition: detected.h:21
nonesuch(nonesuch const &&)=delete
~nonesuch()=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete