![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
Either a value or a BrokerError. More...
#include <algotradelib/src/core/types.hpp>
Public Member Functions | |
| Result (T value) | |
| Constructs a successful result. | |
| Result (BrokerError error) | |
| Constructs a failed result. | |
| bool | has_value () const noexcept |
| Tests whether the result holds a value. | |
| operator bool () const noexcept | |
| Tests whether the result holds a value. | |
| T & | value () |
| Returns the value. | |
| const T & | value () const |
| Returns the value. | |
| BrokerError & | error () |
| Returns the error. | |
| const BrokerError & | error () const |
| Returns the error. | |
Either a value or a BrokerError.
Test it with has_value() (or if (result)) before calling value() or error(); the wrong accessor throws std::bad_variant_access.
| T | The value type. |
|
inline |
Constructs a successful result.
| value | The value. |
Definition at line 1064 of file types.hpp.
Referenced by algotradelib::alpaca::AlpacaBlockingClient::bars(), algotradelib::BlockingSession< Client >::bars(), algotradelib::mock::Market::bars(), algotradelib::mock::MockClient::bars(), algotradelib::mock::Market::buying_power(), algotradelib::alpaca::AlpacaBlockingClient::calendar(), algotradelib::BlockingSession< Client >::calendar(), algotradelib::mock::Market::calendar(), algotradelib::mock::MockClient::calendar(), algotradelib::BlockingSession< Client >::cancel(), algotradelib::alpaca::AlpacaBlockingClient::cancel_order(), algotradelib::DataOnlyTraits< Tag >::cancel_order(), algotradelib::backtest::CommissionPolicy::charge(), algotradelib::backtest::commission_model_from(), algotradelib::DataOnlyTraits< Tag >::holdings(), algotradelib::mock::Market::holdings(), algotradelib::alpaca::AlpacaBlockingClient::instrument(), algotradelib::mock::Market::instrument(), algotradelib::mock::MockClient::instrument(), algotradelib::alpaca::AlpacaBlockingClient::order_by_id(), algotradelib::BlockingSession< Client >::order_history(), algotradelib::DataOnlyTraits< Tag >::order_history(), algotradelib::mock::MockClient::order_history(), algotradelib::BlockingSession< Client >::place(), algotradelib::alpaca::AlpacaBlockingClient::place_order(), algotradelib::DataOnlyTraits< Tag >::place_order(), algotradelib::data_only::post_refusal(), algotradelib::alpaca::AlpacaBlockingClient::quote(), algotradelib::mock::Market::quote(), algotradelib::mock::MockClient::quote(), algotradelib::BlockingSession< Client >::replace(), algotradelib::BrokerTraits< alpaca::AlpacaBlockingClient >::replace_order(), algotradelib::BrokerTraits< mock::MockClient >::replace_order(), algotradelib::DataOnlyTraits< Tag >::replace_order(), algotradelib::backtest::CommissionPolicy::scheduled(), algotradelib::BrokerTraits< alpaca::AlpacaBlockingClient >::to_cancellation(), algotradelib::BrokerTraits< mock::MockClient >::to_cancellation(), algotradelib::DataOnlyTraits< Tag >::to_cancellation(), algotradelib::BrokerTraits< alpaca::AlpacaBlockingClient >::to_history_query(), algotradelib::BrokerTraits< mock::MockClient >::to_history_query(), algotradelib::DataOnlyTraits< Tag >::to_history_query(), algotradelib::BrokerTraits< alpaca::AlpacaBlockingClient >::to_replacement(), algotradelib::BrokerTraits< mock::MockClient >::to_replacement(), and algotradelib::DataOnlyTraits< Tag >::to_replacement().
|
inline |
|
inline |
Returns the error.
| std::bad_variant_access | if the result holds a value. |
Definition at line 1111 of file types.hpp.
Referenced by algotradelib::BrokerTraits< alpaca::AlpacaBlockingClient >::normalize_place(), algotradelib::DataOnlyTraits< Tag >::normalize_place(), algotradelib::BrokerTraits< alpaca::AlpacaBlockingClient >::normalize_working_orders(), and Result().
|
inline |
|
inlinenoexcept |
Tests whether the result holds a value.
Definition at line 1076 of file types.hpp.
Referenced by operator bool().
|
inlineexplicitnoexcept |
|
inline |
Returns the value.
| std::bad_variant_access | if the result holds an error. |
Definition at line 1093 of file types.hpp.
Referenced by algotradelib::BrokerTraits< alpaca::AlpacaBlockingClient >::normalize_place(), algotradelib::BrokerTraits< alpaca::AlpacaBlockingClient >::normalize_working_orders(), and Result().
|
inline |