DAW JSON Link
Loading...
Searching...
No Matches
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
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
20namespace daw::json {
21 inline namespace DAW_JSON_VER {
23 static constexpr std::string_view name = "default_mode";
24 };
26 static constexpr std::string_view name = "constexpr";
27 };
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
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
Customization point traits.
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.
Definition version.h:20