31#ifndef ETL_RESULT_INCLUDED
32#define ETL_RESULT_INCLUDED
41#if ETL_CPP11_NOT_SUPPORTED
42 #if !defined(ETL_IN_UNIT_TEST)
43 #error NOT SUPPORTED FOR C++03 OR BELOW
52 template <
typename TValue,
typename TError>
57 typedef TValue value_type;
58 typedef TError error_type;
68 result(
const result& other)
73 #if ETL_CPP11_SUPPORTED
77 result(result&& other)
86 result(
const TValue& value)
94 result(TValue&& value)
95 :
data(etl::move(value))
102 result(
const TError& error)
110 #if ETL_CPP11_SUPPORTED
111 result(TError&& error)
112 :
data(etl::move(error))
120 result& operator=(
const result& other)
129 result& operator=(result&& other)
131 data = etl::move(other.data);
138 result& operator=(
const TValue& value)
147 #if ETL_CPP11_SUPPORTED
148 result& operator=(TValue&& value)
150 data = etl::move(value);
158 result& operator=(
const TError& error)
167 #if ETL_CPP11_SUPPORTED
168 result& operator=(TError&& error)
170 data = etl::move(error);
178 bool has_value()
const
180 return (
data.index() == 0U);
186 bool is_value()
const
194 bool is_error()
const
203 const TValue& value()
const
221 const TError& error()
const
230 #if ETL_CPP11_SUPPORTED
239 etl::variant<TValue, TError>
data;
246 template <
typename TError>
247 class result<void, TError>
251 typedef void value_type;
252 typedef TError error_type;
262 result(
const result& other)
270 result(result&& other)
278 result(
const TError& error)
286 #if ETL_CPP11_SUPPORTED
287 result(TError&& error)
288 :
data(etl::move(error))
296 result& operator=(
const TError& error)
305 #if ETL_CPP11_SUPPORTED
306 result& operator=(TError&& error)
308 data = etl::move(error);
316 bool has_value()
const
318 return !
data.has_value();
324 bool is_value()
const
332 bool is_error()
const
341 const TError& error()
const
350 #if ETL_CPP11_SUPPORTED
353 return etl::move(
data.value());
359 etl::optional<TError>
data;
366 template <
typename TValue>
367 class result<TValue, void>
379 result(
const result& other)
387 result(result&& other)
395 result(
const TValue& value)
403 result(TValue&& value)
404 :
data(etl::move(value))
411 result& operator=(
const TValue& value)
420 result& operator=(TValue&& value)
422 data = etl::move(value);
429 bool has_value()
const
431 return data.has_value();
437 bool is_value()
const
445 bool is_error()
const
454 const TValue& value()
const
465 return etl::move(
data.value());
470 etl::optional<TValue>
data;
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR TContainer::pointer data(TContainer &container)
Definition iterator.h:1228
T & get(array< T, Size > &a)
Definition array.h:1161