simdjson 4.0.7
Ridiculously Fast JSON
Loading...
Searching...
No Matches
implementation_simdjson_result_base.h
1#ifndef SIMDJSON_GENERIC_IMPLEMENTATION_SIMDJSON_RESULT_BASE_H
2
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_IMPLEMENTATION_SIMDJSON_RESULT_BASE_H
5#include "simdjson/generic/base.h"
6#endif // SIMDJSON_CONDITIONAL_INCLUDE
7
8namespace simdjson {
9namespace SIMDJSON_IMPLEMENTATION {
10
11// This is a near copy of include/error.h's implementation_simdjson_result_base, except it doesn't use std::pair
12// so we can avoid inlining errors
13// TODO reconcile these!
34template<typename T>
36
40 simdjson_inline implementation_simdjson_result_base() noexcept = default;
41
46
50 simdjson_inline implementation_simdjson_result_base(T &&value) noexcept;
51
55 simdjson_inline implementation_simdjson_result_base(T &&value, error_code error) noexcept;
56
63 simdjson_inline void tie(T &value, error_code &error) && noexcept;
64
70 simdjson_warn_unused simdjson_inline error_code get(T &value) && noexcept;
71
75 simdjson_warn_unused simdjson_inline error_code error() const noexcept;
76
80 simdjson_warn_unused simdjson_inline bool has_value() const noexcept;
81
82#if SIMDJSON_EXCEPTIONS
83
89 simdjson_inline T& operator*() & noexcept(false);
90 simdjson_inline T&& operator*() && noexcept(false);
96 simdjson_inline T* operator->() noexcept(false);
97 simdjson_inline const T* operator->() const noexcept(false);
98
99 simdjson_inline T& value() & noexcept(false);
100
106 simdjson_inline T&& value() && noexcept(false);
107
113 simdjson_inline T&& take_value() && noexcept(false);
114
120 simdjson_inline operator T&&() && noexcept(false);
121
122
123#endif // SIMDJSON_EXCEPTIONS
124
129 simdjson_inline const T& value_unsafe() const& noexcept;
134 simdjson_inline T& value_unsafe() & noexcept;
139 simdjson_inline T&& value_unsafe() && noexcept;
140
141protected:
143 T first{};
145}; // struct implementation_simdjson_result_base
146
147} // namespace SIMDJSON_IMPLEMENTATION
148} // namespace simdjson
149
150#endif // SIMDJSON_GENERIC_IMPLEMENTATION_SIMDJSON_RESULT_BASE_H
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8
error_code
All possible errors returned by simdjson.
Definition error.h:19
@ UNINITIALIZED
unknown error, or uninitialized document
Definition error.h:32
simdjson_inline implementation_simdjson_result_base() noexcept=default
Create a new empty result with error = UNINITIALIZED.
simdjson_warn_unused simdjson_inline bool has_value() const noexcept
Whether there is a value.
simdjson_inline const T & value_unsafe() const &noexcept
Get the result value.
simdjson_warn_unused simdjson_inline error_code get(T &value) &&noexcept
Move the value to the provided variable.
simdjson_inline void tie(T &value, error_code &error) &&noexcept
Move the value and the error to the provided variables.
simdjson_inline T * operator->() noexcept(false)
Arrow operator to access members of the contained value.
simdjson_warn_unused simdjson_inline error_code error() const noexcept
The error.
simdjson_inline T && take_value() &&noexcept(false)
Take the result value (move it).