DAW JSON Link
Loading...
Searching...
No Matches
include
daw
json
impl
daw_json_exec_modes.h
Go to the documentation of this file.
1
// Copyright (c) Darrell Wright
2
//
3
// Distributed under the Boost Software License, Version 1.0. (See accompanying
4
// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
5
//
6
// Official repository: https://github.com/beached/daw_json_link
7
//
8
9
#pragma once
10
11
#include "
daw/json/daw_json_switches.h
"
12
#include "
daw/json/impl/version.h
"
13
14
#include <daw/daw_cpp_feature_check.h>
15
#include <daw/daw_is_constant_evaluated.h>
16
17
#include <string_view>
18
#include <type_traits>
19
20
namespace
daw::json
{
21
inline
namespace
DAW_JSON_VER
{
22
struct
default_exec_tag
{
23
static
constexpr
std::string_view name =
"default_mode"
;
24
};
25
struct
constexpr_exec_tag
:
default_exec_tag
{
26
static
constexpr
std::string_view name =
"constexpr"
;
27
};
28
struct
runtime_exec_tag
:
constexpr_exec_tag
{
29
static
constexpr
std::string_view name =
"runtime"
;
30
};
31
#if defined( DAW_ALLOW_SSE42 )
32
struct
sse42_exec_tag :
runtime_exec_tag
{
33
static
constexpr
std::string_view name =
"sse4.2"
;
34
};
35
using
simd_exec_tag
= sse42_exec_tag;
36
#else
37
struct
simd_exec_tag
:
runtime_exec_tag
{
38
static
constexpr
std::string_view name =
"simd"
;
39
};
40
#endif
41
42
namespace
json_details {
43
template
<
typename
ExecTag>
44
DAW_ATTRIB_INLINE
constexpr
bool
use_constexpr_exec_mode( ) {
45
#if defined( DAW_HAS_IF_CONSTEVAL )
46
if
consteval
{
47
return
true
;
48
}
49
#elif defined( DAW_HAS_IS_CONSTANT_EVALUATED )
50
if
( DAW_IS_CONSTANT_EVALUATED( ) ) {
51
return
true
;
52
}
53
#endif
54
// Either we cannot detect if we are being constant evaluated or we are
55
// in fact not being constant evaluated. If they asked for runtime, use
56
// it.
57
return
not std::is_base_of_v<runtime_exec_tag, ExecTag>;
58
}
59
}
// namespace json_details
60
}
// namespace DAW_JSON_VER
61
}
// namespace daw::json
daw_json_switches.h
daw::json
Customization point traits.
Definition
daw_container_traits.h:24
daw::json::anonymous_namespace{daw_json_exec_modes.h}::constexpr_exec_tag
Definition
daw_json_exec_modes.h:25
daw::json::anonymous_namespace{daw_json_exec_modes.h}::default_exec_tag
Definition
daw_json_exec_modes.h:22
daw::json::anonymous_namespace{daw_json_exec_modes.h}::runtime_exec_tag
Definition
daw_json_exec_modes.h:28
daw::json::simd_exec_tag
Definition
daw_json_exec_modes.h:37
version.h
DAW_JSON_VER
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.
Definition
version.h:20
Generated by
1.9.8