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 {
47 template<typename ExecTag>
48 DAW_ATTRIB_INLINE constexpr bool use_constexpr_exec_mode( ) {
49#if defined( DAW_HAS_IF_CONSTEVAL )
50 if consteval {
51 return true;
52 } else {
53 return false;
54 }
55#elif defined( DAW_HAS_IS_CONSTANT_EVALUATED )
56 return DAW_IS_CONSTANT_EVALUATED( );
57#else
58 // Cannot detect constant evaluation, only leave the constexpr code
59 // paths when the runtime or simd exec mode was asked for
60 return not std::is_base_of_v<runtime_exec_tag, ExecTag>;
61#endif
62 }
63
68 template<typename ExecTag>
69 DAW_ATTRIB_INLINE constexpr bool use_simd_exec_mode( ) {
70#if defined( DAW_HAS_IF_CONSTEVAL ) or defined( DAW_HAS_IS_CONSTANT_EVALUATED )
71 return true;
72#else
73 return std::is_base_of_v<simd_exec_tag, ExecTag>;
74#endif
75 }
76 } // namespace json_details
77 } // namespace DAW_JSON_VER
78} // namespace daw::json
string_writer grows its string with resize_and_overwrite, leaving the new bytes uninitialized,...
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.
Definition version.h:20