2017-07-27 16:08:31 +02:00
|
|
|
// Copyright (c) 2017 The Bitcoin Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_OPTIONAL_H
|
|
|
|
#define BITCOIN_OPTIONAL_H
|
|
|
|
|
2019-01-30 12:28:41 +01:00
|
|
|
#include <utility>
|
|
|
|
|
2017-07-27 16:08:31 +02:00
|
|
|
#include <boost/optional.hpp>
|
|
|
|
|
|
|
|
//! Substitute for C++17 std::optional
|
|
|
|
template <typename T>
|
|
|
|
using Optional = boost::optional<T>;
|
|
|
|
|
2019-01-30 12:28:41 +01:00
|
|
|
//! Substitute for C++17 std::make_optional
|
|
|
|
template <typename T>
|
|
|
|
Optional<T> MakeOptional(bool condition, T&& value)
|
|
|
|
{
|
|
|
|
return boost::make_optional(condition, std::forward<T>(value));
|
|
|
|
}
|
|
|
|
|
2017-07-27 16:08:31 +02:00
|
|
|
//! Substitute for C++17 std::nullopt
|
|
|
|
static auto& nullopt = boost::none;
|
|
|
|
|
|
|
|
#endif // BITCOIN_OPTIONAL_H
|