mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 05:23:01 +01:00
0645d47320
2d483142a7051389afe74c57a216843e6306f1a8 Remove 'boost::optional'-related gcc warnings (Hennadii Stepanov) Pull request description: #14711 introduced some warnings when building with gcc compiler. See: - https://github.com/bitcoin/bitcoin/pull/14711#issuecomment-454760017 by @laanwj - https://github.com/bitcoin/bitcoin/pull/14711#pullrequestreview-193702611 by @ryanofsky This gcc [issue](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47679) has been known since version 4.6.0 and last updated in 2017. From the boost [docs](https://www.boost.org/doc/libs/1_69_0/libs/optional/doc/html/boost_optional/quick_start/optional_automatic_variables.html): > The default constructor of `optional` creates an _uninitialized_ `optional` object. Also: [False positive with -Wmaybe-uninitialized](https://www.boost.org/doc/libs/1_69_0/libs/optional/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html) ([pointed out](https://github.com/bitcoin/bitcoin/pull/15292#issuecomment-459063170) by @Empact) This PR removes these warnings. cc: @Empact @practicalswift Tree-SHA512: 752ae3c3ca6282bbf98726236fbc3069ab9d1aee57ae2ec2668b32e4541e7bc1acb15b7d6fa9e2b6daf1ec29c0987a1053ee1ca0f523b71367ff911221c58c94 Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
27 lines
690 B
C++
27 lines
690 B
C++
// 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
|
|
|
|
#include <utility>
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
//! Substitute for C++17 std::optional
|
|
template <typename T>
|
|
using Optional = boost::optional<T>;
|
|
|
|
//! 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));
|
|
}
|
|
|
|
//! Substitute for C++17 std::nullopt
|
|
static auto& nullopt = boost::none;
|
|
|
|
#endif // BITCOIN_OPTIONAL_H
|