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)
78 : data(
etl::move(other.data))
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
246 template<
typename TError>
247 class result<void, TError>
251 typedef void value_type;
252 typedef TError error_type;
264 result(
const result& other)
272 result(result&& other)
273 : data(
etl::move(other.data))
280 result(
const TError& error)
288#if ETL_CPP11_SUPPORTED
289 result(TError&& error)
290 : data(
etl::move(error))
298 result& operator =(
const TError& error)
307#if ETL_CPP11_SUPPORTED
308 result& operator =(TError&& error)
310 data = etl::move(error);
318 bool has_value()
const
320 return !data.has_value();
326 bool is_value()
const
334 bool is_error()
const
343 const TError& error()
const
352#if ETL_CPP11_SUPPORTED
355 return etl::move(data.value());
368 template<
typename TValue>
369 class result<TValue, void>
383 result(
const result& other)
391 result(result&& other)
392 : data(
etl::move(other.data))
399 result(
const TValue& value)
407 result(TValue&& value)
408 : data(
etl::move(value))
415 result& operator =(
const TValue& value)
424 result& operator =(TValue&& value)
426 data = etl::move(value);
433 bool has_value()
const
435 return data.has_value();
441 bool is_value()
const
449 bool is_error()
const
458 const TValue& value()
const
469 return etl::move(data.value());
bitset_ext
Definition absolute.h:38
pair holds two objects of arbitrary type
Definition utility.h:164