1namespace simdjson {
2namespace SIMDJSON_IMPLEMENTATION {
3
4//
5// internal::implementation_simdjson_result_base<T> inline implementation
6//
7
8template<typename T>
9simdjson_inline void implementation_simdjson_result_base<T>::tie(T &value, error_code &error) && noexcept {
10 error = this->second;
11 if (!error) {
12 value = std::forward<implementation_simdjson_result_base<T>>(*this).first;
13 }
14}
15
16template<typename T>
17simdjson_warn_unused simdjson_inline error_code implementation_simdjson_result_base<T>::get(T &value) && noexcept {
18 error_code error;
19 std::forward<implementation_simdjson_result_base<T>>(*this).tie(value, error);
20 return error;
21}
22
23template<typename T>
24simdjson_inline error_code implementation_simdjson_result_base<T>::error() const noexcept {
25 return this->second;
26}
27
28#if SIMDJSON_EXCEPTIONS
29
30template<typename T>
31simdjson_inline T& implementation_simdjson_result_base<T>::value() & noexcept(false) {
32 if (error()) { throw simdjson_error(error()); }
33 return this->first;
34}
35
36template<typename T>
37simdjson_inline T&& implementation_simdjson_result_base<T>::value() && noexcept(false) {
38 return std::forward<implementation_simdjson_result_base<T>>(*this).take_value();
39}
40
41template<typename T>
42simdjson_inline T&& implementation_simdjson_result_base<T>::take_value() && noexcept(false) {
43 if (error()) { throw simdjson_error(error()); }
44 return std::forward<T>(this->first);
45}
46
47template<typename T>
48simdjson_inline implementation_simdjson_result_base<T>::operator T&&() && noexcept(false) {
49 return std::forward<implementation_simdjson_result_base<T>>(*this).take_value();
50}
51
52#endif // SIMDJSON_EXCEPTIONS
53
54template<typename T>
55simdjson_inline const T& implementation_simdjson_result_base<T>::value_unsafe() const& noexcept {
56 return this->first;
57}
58
59template<typename T>
60simdjson_inline T& implementation_simdjson_result_base<T>::value_unsafe() & noexcept {
61 return this->first;
62}
63
64template<typename T>
65simdjson_inline T&& implementation_simdjson_result_base<T>::value_unsafe() && noexcept {
66 return std::forward<T>(this->first);
67}
68
69template<typename T>
70simdjson_inline implementation_simdjson_result_base<T>::implementation_simdjson_result_base(T &&value, error_code error) noexcept
71 : first{std::forward<T>(value)}, second{error} {}
72template<typename T>
73simdjson_inline implementation_simdjson_result_base<T>::implementation_simdjson_result_base(error_code error) noexcept
74 : implementation_simdjson_result_base(T{}, error) {}
75template<typename T>
76simdjson_inline implementation_simdjson_result_base<T>::implementation_simdjson_result_base(T &&value) noexcept
77 : implementation_simdjson_result_base(std::forward<T>(value), SUCCESS) {}
78
79} // namespace SIMDJSON_IMPLEMENTATION
80} // namespace simdjson
81