From 570bb2e13920e386f10f1295cf1e62ca41fce05d Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Tue, 6 Oct 2015 12:38:26 -0700 Subject: [PATCH] Use more C++11 features: * Remove beast::static_initializer * Remove noexcept VS2013 workaround * Use [[noreturn]] attribute --- Builds/VisualStudio2015/RippleD.vcxproj | 7 - .../VisualStudio2015/RippleD.vcxproj.filters | 9 - src/beast/beast/Arithmetic.h | 2 - src/beast/beast/chrono/RelativeTime.h | 1 - src/beast/beast/chrono/chrono_io.h | 1 - src/beast/beast/config/compiler/VisualC.h | 1 - src/beast/beast/crypto/detail/mac_facade.h | 1 - .../beast/crypto/detail/ripemd_context.h | 1 - src/beast/beast/crypto/detail/sha2_context.h | 1 - src/beast/beast/hash/fnv1a.h | 1 - src/beast/beast/hash/hash_append.h | 1 - src/beast/beast/hash/siphash.h | 1 - src/beast/beast/hash/xxhasher.h | 1 - src/beast/beast/http/URL.h | 15 - src/beast/beast/http/basic_parser.h | 1 - src/beast/beast/http/impl/basic_parser.cpp | 1 - src/beast/beast/http/message.h | 39 --- src/beast/beast/http/parser.h | 18 -- .../module/core/diagnostic/FatalError.cpp | 54 ++-- .../beast/module/core/diagnostic/FatalError.h | 6 +- .../module/core/diagnostic/SemanticVersion.h | 2 - src/beast/beast/module/core/files/File.cpp | 5 +- .../module/core/thread/DeadlineTimer.cpp | 6 +- src/beast/beast/net/IPAddress.h | 1 - src/beast/beast/nudb/detail/gentex.h | 1 - src/beast/beast/threads/SpinLock.h | 1 - src/beast/beast/unit_test/suite.h | 1 - src/beast/beast/unit_test/thread.h | 1 - src/beast/beast/utility/Utility.unity.cpp | 1 - .../beast/utility/empty_base_optimization.h | 1 - src/beast/beast/utility/impl/Journal.cpp | 5 +- src/beast/beast/utility/noexcept.h | 39 --- src/beast/beast/utility/static_initializer.h | 258 ------------------ src/beast/beast/utility/tagged_integer.h | 2 - .../utility/tests/static_initializer.test.cpp | 209 -------------- src/ripple/app/tx/impl/BookTip.h | 1 - src/ripple/app/tx/impl/Offer.h | 1 - src/ripple/app/tx/impl/OfferStream.h | 1 - src/ripple/app/tx/impl/Taker.h | 1 - src/ripple/basics/Buffer.h | 1 - src/ripple/basics/CountedObject.h | 6 +- src/ripple/basics/Log.h | 1 - src/ripple/basics/RangeSet.h | 1 - src/ripple/basics/Slice.h | 1 - src/ripple/basics/contract.h | 6 +- src/ripple/basics/hardened_hash.h | 14 +- src/ripple/basics/impl/contract.cpp | 12 +- src/ripple/basics/impl/make_SSLContext.cpp | 5 +- src/ripple/basics/make_SSLContext.h | 1 - src/ripple/crypto/Base58Data.h | 2 - src/ripple/json/Object.h | 8 +- src/ripple/ledger/ApplyViewImpl.h | 9 - src/ripple/ledger/OpenView.h | 14 - src/ripple/ledger/PaymentSandbox.h | 9 - src/ripple/ledger/Sandbox.h | 7 - src/ripple/ledger/detail/ApplyStateTable.h | 12 +- src/ripple/ledger/detail/ApplyViewBase.h | 13 +- src/ripple/ledger/detail/RawStateTable.h | 12 +- src/ripple/ledger/tests/PathSet.h | 26 +- src/ripple/nodestore/impl/EncodedBlob.h | 1 - src/ripple/nodestore/impl/ManagerImp.cpp | 4 +- src/ripple/overlay/impl/Manifest.h | 34 +-- src/ripple/overlay/impl/TMHello.cpp | 5 +- src/ripple/protocol/HashPrefix.h | 1 - src/ripple/protocol/IOUAmount.h | 1 - src/ripple/protocol/PublicKey.h | 1 - src/ripple/protocol/Quality.h | 1 - src/ripple/protocol/Rate.h | 1 - src/ripple/protocol/RippleAddress.h | 1 - src/ripple/protocol/SField.h | 19 +- src/ripple/protocol/STObject.h | 1 - src/ripple/protocol/Serializer.h | 1 - src/ripple/protocol/XRPAmount.h | 1 - src/ripple/protocol/digest.h | 1 - src/ripple/protocol/impl/Indexes.cpp | 5 +- src/ripple/protocol/impl/PublicKey.cpp | 1 - src/ripple/protocol/impl/SField.cpp | 20 +- src/ripple/protocol/impl/STObject.cpp | 4 +- src/ripple/protocol/impl/STVar.h | 1 - src/ripple/protocol/impl/SecretKey.cpp | 10 +- src/ripple/protocol/impl/TxFormats.cpp | 6 +- src/ripple/protocol/impl/UintTypes.cpp | 5 +- src/ripple/protocol/impl/secp256k1.h | 5 +- src/ripple/rpc/handlers/AccountObjects.cpp | 31 +-- src/ripple/rpc/impl/Handler.cpp | 4 +- src/ripple/shamap/impl/SHAMapNodeID.cpp | 5 +- src/ripple/test/jtx/Account.h | 2 - src/ripple/test/jtx/JTx.h | 47 +--- src/ripple/unl/tests/qalloc.h | 4 +- 89 files changed, 113 insertions(+), 969 deletions(-) delete mode 100644 src/beast/beast/utility/noexcept.h delete mode 100644 src/beast/beast/utility/static_initializer.h delete mode 100644 src/beast/beast/utility/tests/static_initializer.test.cpp diff --git a/Builds/VisualStudio2015/RippleD.vcxproj b/Builds/VisualStudio2015/RippleD.vcxproj index 9ea9e9d806..addddc7a9e 100644 --- a/Builds/VisualStudio2015/RippleD.vcxproj +++ b/Builds/VisualStudio2015/RippleD.vcxproj @@ -1030,12 +1030,8 @@ - - - - @@ -1047,9 +1043,6 @@ True - - True - True diff --git a/Builds/VisualStudio2015/RippleD.vcxproj.filters b/Builds/VisualStudio2015/RippleD.vcxproj.filters index 2c2ef8db1e..e36fa09c17 100644 --- a/Builds/VisualStudio2015/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2015/RippleD.vcxproj.filters @@ -1698,15 +1698,9 @@ beast\utility - - beast\utility - beast\utility - - beast\utility - beast\utility @@ -1719,9 +1713,6 @@ beast\utility\tests - - beast\utility\tests - beast\utility\tests diff --git a/src/beast/beast/Arithmetic.h b/src/beast/beast/Arithmetic.h index edc285731a..2add9c4601 100644 --- a/src/beast/beast/Arithmetic.h +++ b/src/beast/beast/Arithmetic.h @@ -26,8 +26,6 @@ #include -#include - #include #include #include diff --git a/src/beast/beast/chrono/RelativeTime.h b/src/beast/beast/chrono/RelativeTime.h index 0e42e4144d..76809b4a07 100644 --- a/src/beast/beast/chrono/RelativeTime.h +++ b/src/beast/beast/chrono/RelativeTime.h @@ -27,7 +27,6 @@ #include #include -#include #include #include diff --git a/src/beast/beast/chrono/chrono_io.h b/src/beast/beast/chrono/chrono_io.h index c17fe96fa1..b9dfacdfbe 100644 --- a/src/beast/beast/chrono/chrono_io.h +++ b/src/beast/beast/chrono/chrono_io.h @@ -29,7 +29,6 @@ #include -#include #include #include diff --git a/src/beast/beast/config/compiler/VisualC.h b/src/beast/beast/config/compiler/VisualC.h index 84b47018cc..e360cdd6b6 100644 --- a/src/beast/beast/config/compiler/VisualC.h +++ b/src/beast/beast/config/compiler/VisualC.h @@ -22,5 +22,4 @@ #ifndef BEAST_CONFIG_COMPILER_VISUALC_H_INCLUDED #define BEAST_CONFIG_COMPILER_VISUALC_H_INCLUDED -#include #endif diff --git a/src/beast/beast/crypto/detail/mac_facade.h b/src/beast/beast/crypto/detail/mac_facade.h index 6dd7ff8b86..c30217431e 100644 --- a/src/beast/beast/crypto/detail/mac_facade.h +++ b/src/beast/beast/crypto/detail/mac_facade.h @@ -22,7 +22,6 @@ #include #include -#include #include #include diff --git a/src/beast/beast/crypto/detail/ripemd_context.h b/src/beast/beast/crypto/detail/ripemd_context.h index 391fd3d4e6..0b89921bbd 100644 --- a/src/beast/beast/crypto/detail/ripemd_context.h +++ b/src/beast/beast/crypto/detail/ripemd_context.h @@ -20,7 +20,6 @@ #ifndef BEAST_CRYPTO_RIPEMD_CONTEXT_H_INCLUDED #define BEAST_CRYPTO_RIPEMD_CONTEXT_H_INCLUDED -#include #include #include #include diff --git a/src/beast/beast/crypto/detail/sha2_context.h b/src/beast/beast/crypto/detail/sha2_context.h index 4cb3449fde..6786fca92a 100644 --- a/src/beast/beast/crypto/detail/sha2_context.h +++ b/src/beast/beast/crypto/detail/sha2_context.h @@ -20,7 +20,6 @@ #ifndef BEAST_CRYPTO_SHA512_CONTEXT_H_INCLUDED #define BEAST_CRYPTO_SHA512_CONTEXT_H_INCLUDED -#include #include #include diff --git a/src/beast/beast/hash/fnv1a.h b/src/beast/beast/hash/fnv1a.h index eec288018c..0e465d65f4 100644 --- a/src/beast/beast/hash/fnv1a.h +++ b/src/beast/beast/hash/fnv1a.h @@ -21,7 +21,6 @@ #ifndef BEAST_HASH_FNV1A_H_INCLUDED #define BEAST_HASH_FNV1A_H_INCLUDED -#include #include #include #include // diff --git a/src/beast/beast/hash/hash_append.h b/src/beast/beast/hash/hash_append.h index 6a5365ac9e..bcb953d695 100644 --- a/src/beast/beast/hash/hash_append.h +++ b/src/beast/beast/hash/hash_append.h @@ -24,7 +24,6 @@ #include // for constexpr #include #include -#include #include #include #include diff --git a/src/beast/beast/hash/siphash.h b/src/beast/beast/hash/siphash.h index eeabfdcae7..e4a4b363fb 100644 --- a/src/beast/beast/hash/siphash.h +++ b/src/beast/beast/hash/siphash.h @@ -21,7 +21,6 @@ #ifndef BEAST_HASH_SIPHASH_H_INCLUDED #define BEAST_HASH_SIPHASH_H_INCLUDED -#include #include #include diff --git a/src/beast/beast/hash/xxhasher.h b/src/beast/beast/hash/xxhasher.h index c17d5ef5c1..5525a84504 100644 --- a/src/beast/beast/hash/xxhasher.h +++ b/src/beast/beast/hash/xxhasher.h @@ -28,7 +28,6 @@ #include #include -#include #include // #include diff --git a/src/beast/beast/http/URL.h b/src/beast/beast/http/URL.h index 459e5a6687..dd7fd80722 100644 --- a/src/beast/beast/http/URL.h +++ b/src/beast/beast/http/URL.h @@ -52,22 +52,7 @@ public: URL& operator= (URL const& other) = default; /** Move construct a URL. */ -#ifdef _MSC_VER - URL (URL&& other) - : m_scheme(std::move(other.m_scheme)) - , m_host(std::move(other.m_host)) - , m_port(other.m_port) - , m_port_string(std::move(other.m_port_string)) - , m_path(std::move(other.m_path)) - , m_query(std::move(other.m_query)) - , m_fragment(std::move(other.m_fragment)) - , m_userinfo(std::move(other.m_userinfo)) - { - } - -#else URL (URL&& other) = default; -#endif /** Returns `true` if this is an empty URL. */ bool diff --git a/src/beast/beast/http/basic_parser.h b/src/beast/beast/http/basic_parser.h index a0397f49c3..d0ee4dcffb 100644 --- a/src/beast/beast/http/basic_parser.h +++ b/src/beast/beast/http/basic_parser.h @@ -27,7 +27,6 @@ #include #include #include -#include namespace beast { diff --git a/src/beast/beast/http/impl/basic_parser.cpp b/src/beast/beast/http/impl/basic_parser.cpp index a31a14b4b6..0d02380b33 100644 --- a/src/beast/beast/http/impl/basic_parser.cpp +++ b/src/beast/beast/http/impl/basic_parser.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include namespace beast { diff --git a/src/beast/beast/http/message.h b/src/beast/beast/http/message.h index 4d859d14a9..85dfe1913d 100644 --- a/src/beast/beast/http/message.h +++ b/src/beast/beast/http/message.h @@ -76,16 +76,9 @@ public: template message(); -#if defined(_MSC_VER) && _MSC_VER <= 1800 - message (message&& other); - message& operator= (message&& other); - -#else message (message&& other) = default; message& operator= (message&& other) = default; -#endif - // Memberspace beast::http::headers headers; @@ -220,38 +213,6 @@ message::message() { } -#if defined(_MSC_VER) && _MSC_VER <= 1800 -inline -message::message (message&& other) - : request_ (other.request_) - , method_ (std::move(other.method_)) - , url_ (std::move(other.url_)) - , status_ (other.status_) - , reason_ (std::move(other.reason_)) - , version_ (other.version_) - , keep_alive_ (other.keep_alive_) - , upgrade_ (other.upgrade_) - , headers (std::move(other.headers)) -{ -} - -inline -message& -message::operator= (message&& other) -{ - request_ = other.request_; - method_ = std::move(other.method_); - url_ = std::move(other.url_); - status_ = other.status_; - reason_ = std::move(other.reason_); - version_ = other.version_; - keep_alive_ = other.keep_alive_; - upgrade_ = other.upgrade_; - headers = std::move(other.headers); - return *this; -} -#endif - //------------------------------------------------------------------------------ template diff --git a/src/beast/beast/http/parser.h b/src/beast/beast/http/parser.h index 2619d050aa..36f784c63f 100644 --- a/src/beast/beast/http/parser.h +++ b/src/beast/beast/http/parser.h @@ -66,14 +66,8 @@ public: message_.get().request(request); } -#if defined(_MSC_VER) && _MSC_VER <= 1800 - parser& operator= (parser&& other); - -#else parser& operator= (parser&& other) = default; -#endif - private: template void @@ -141,18 +135,6 @@ private: }; //------------------------------------------------------------------------------ - -#if defined(_MSC_VER) && _MSC_VER <= 1800 -inline -parser& -parser::operator= (parser&& other) -{ - basic_parser::operator= (std::move(other)); - message_ = std::move (other.message_); - return *this; -} -#endif - template void parser::do_start() diff --git a/src/beast/beast/module/core/diagnostic/FatalError.cpp b/src/beast/beast/module/core/diagnostic/FatalError.cpp index e8d7b2f7e9..146041b774 100644 --- a/src/beast/beast/module/core/diagnostic/FatalError.cpp +++ b/src/beast/beast/module/core/diagnostic/FatalError.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -27,49 +28,38 @@ namespace beast { //------------------------------------------------------------------------------ +[[noreturn]] void -FatalError (char const* message, char const* file, int line) +FatalError ( + char const* message, + char const* file, + int line) noexcept { - static std::atomic error_count (0); - static std::recursive_mutex gate; + static std::mutex gate; // We only allow one thread to report a fatal error. Other threads that // encounter fatal errors while we are reporting get blocked here. - std::lock_guard lock(gate); + std::lock_guard lock(gate); - // If we encounter a recursive fatal error, then we want to terminate - // unconditionally. - if (error_count++ != 0) - return std::terminate (); + std::cerr << "An error has occurred. The application will terminate.\n"; - // We protect this entire block of code since writing to cerr might trigger - // exceptions. - try + if (message != nullptr && message [0] != 0) + std::cerr << "Message: " << message << '\n'; + + if (file != nullptr && file [0] != 0) + std::cerr << " File: " << file << ":" << line << '\n'; + + auto const backtrace = getStackBacktrace (); + + if (!backtrace.empty ()) { - std::cerr << "An error has occurred. The application will terminate.\n"; + std::cerr << " Stack:" << std::endl; - if (message != nullptr && message [0] != 0) - std::cerr << "Message: " << message << '\n'; - - if (file != nullptr && file [0] != 0) - std::cerr << " File: " << file << ":" << line << '\n'; - - auto const backtrace = getStackBacktrace (); - - if (!backtrace.empty ()) - { - std::cerr << " Stack:" << std::endl; - - for (auto const& frame : backtrace) - std::cerr << " " << frame << '\n'; - } - } - catch (...) - { - // nothing we can do - just fall through and terminate + for (auto const& frame : backtrace) + std::cerr << " " << frame << '\n'; } - return std::terminate (); + std::abort (); } } // beast diff --git a/src/beast/beast/module/core/diagnostic/FatalError.h b/src/beast/beast/module/core/diagnostic/FatalError.h index cd6250fd4a..15ee3ba1ee 100644 --- a/src/beast/beast/module/core/diagnostic/FatalError.h +++ b/src/beast/beast/module/core/diagnostic/FatalError.h @@ -35,8 +35,12 @@ namespace beast If multiple threads raise an error, only one will succeed while the others will be blocked before the process terminates. */ +[[noreturn]] void -FatalError (char const* message, char const* file = nullptr, int line = 0); +FatalError ( + char const* message, + char const* file = nullptr, + int line = 0) noexcept; } // beast diff --git a/src/beast/beast/module/core/diagnostic/SemanticVersion.h b/src/beast/beast/module/core/diagnostic/SemanticVersion.h index b55a4ef6b5..9fa8e57a19 100644 --- a/src/beast/beast/module/core/diagnostic/SemanticVersion.h +++ b/src/beast/beast/module/core/diagnostic/SemanticVersion.h @@ -23,8 +23,6 @@ #include #include -#include - namespace beast { /** A Semantic Version number. diff --git a/src/beast/beast/module/core/files/File.cpp b/src/beast/beast/module/core/files/File.cpp index 23bd032d57..613c44bded 100644 --- a/src/beast/beast/module/core/files/File.cpp +++ b/src/beast/beast/module/core/files/File.cpp @@ -21,7 +21,6 @@ */ //============================================================================== -#include #include #include @@ -29,8 +28,8 @@ namespace beast { File const& File::nonexistent() { - static beast::static_initializer instance; - return *instance; + static File const instance; + return instance; } //------------------------------------------------------------------------------ diff --git a/src/beast/beast/module/core/thread/DeadlineTimer.cpp b/src/beast/beast/module/core/thread/DeadlineTimer.cpp index 740b97e23a..60ff3fc567 100644 --- a/src/beast/beast/module/core/thread/DeadlineTimer.cpp +++ b/src/beast/beast/module/core/thread/DeadlineTimer.cpp @@ -17,8 +17,6 @@ */ //============================================================================== -#include - namespace beast { @@ -47,8 +45,8 @@ public: Manager& instance() { - static beast::static_initializer m; - return *m; + static Manager m; + return m; } // Okay to call on an active timer. diff --git a/src/beast/beast/net/IPAddress.h b/src/beast/beast/net/IPAddress.h index 1f42ab41a7..fddd7d6cd0 100644 --- a/src/beast/beast/net/IPAddress.h +++ b/src/beast/beast/net/IPAddress.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/src/beast/beast/nudb/detail/gentex.h b/src/beast/beast/nudb/detail/gentex.h index b64da80886..c0f960cf8a 100644 --- a/src/beast/beast/nudb/detail/gentex.h +++ b/src/beast/beast/nudb/detail/gentex.h @@ -20,7 +20,6 @@ #ifndef BEAST_NUDB_DETAIL_GENTEX_H_INCLUDED #define BEAST_NUDB_DETAIL_GENTEX_H_INCLUDED -#include #include #include #include diff --git a/src/beast/beast/threads/SpinLock.h b/src/beast/beast/threads/SpinLock.h index 4d517da23b..2311fd5418 100644 --- a/src/beast/beast/threads/SpinLock.h +++ b/src/beast/beast/threads/SpinLock.h @@ -25,7 +25,6 @@ #define BEAST_THREADS_SPINLOCK_H_INCLUDED #include -#include #include #include #include diff --git a/src/beast/beast/unit_test/suite.h b/src/beast/beast/unit_test/suite.h index 6a309423ef..6671d57325 100644 --- a/src/beast/beast/unit_test/suite.h +++ b/src/beast/beast/unit_test/suite.h @@ -22,7 +22,6 @@ #include -#include #include #include diff --git a/src/beast/beast/unit_test/thread.h b/src/beast/beast/unit_test/thread.h index b2ac684a7e..fb1fc50cc5 100644 --- a/src/beast/beast/unit_test/thread.h +++ b/src/beast/beast/unit_test/thread.h @@ -20,7 +20,6 @@ #ifndef BEAST_UNIT_TEST_THREAD_H_INCLUDED #define BEAST_UNIT_TEST_THREAD_H_INCLUDED -#include #include #include #include diff --git a/src/beast/beast/utility/Utility.unity.cpp b/src/beast/beast/utility/Utility.unity.cpp index d4313c28af..5eef323fe7 100644 --- a/src/beast/beast/utility/Utility.unity.cpp +++ b/src/beast/beast/utility/Utility.unity.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/src/beast/beast/utility/empty_base_optimization.h b/src/beast/beast/utility/empty_base_optimization.h index 4ab904b47b..22e19e0d35 100644 --- a/src/beast/beast/utility/empty_base_optimization.h +++ b/src/beast/beast/utility/empty_base_optimization.h @@ -21,7 +21,6 @@ #ifndef BEAST_UTILITY_EMPTY_BASE_OPTIMIZATION_H_INCLUDED #define BEAST_UTILITY_EMPTY_BASE_OPTIMIZATION_H_INCLUDED -#include #include #include diff --git a/src/beast/beast/utility/impl/Journal.cpp b/src/beast/beast/utility/impl/Journal.cpp index ec674f6914..6f261614e1 100644 --- a/src/beast/beast/utility/impl/Journal.cpp +++ b/src/beast/beast/utility/impl/Journal.cpp @@ -18,7 +18,6 @@ //============================================================================== #include -#include namespace beast { @@ -60,8 +59,8 @@ public: Journal::Sink& Journal::getNullSink () { - static beast::static_initializer sink; - return *sink; + static NullJournalSink sink; + return sink; } //------------------------------------------------------------------------------ diff --git a/src/beast/beast/utility/noexcept.h b/src/beast/beast/utility/noexcept.h deleted file mode 100644 index 03e177425d..0000000000 --- a/src/beast/beast/utility/noexcept.h +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Portions of this file are from JUCE. - Copyright (c) 2013 - Raw Material Software Ltd. - Please visit http://www.juce.com - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UTILITY_NOEXCEPT_H_INCLUDED -#define BEAST_UTILITY_NOEXCEPT_H_INCLUDED - -#ifdef _MSC_VER -# if _MSC_VER < 1900 -# ifdef noexcept -# undef noexcept -# endif -# define noexcept throw() -# endif -# if _MSC_VER > 1600 && ! _ALLOW_KEYWORD_MACROS -# define _ALLOW_KEYWORD_MACROS 1 // (to stop VC2012 complaining) -# endif -#endif - -#endif diff --git a/src/beast/beast/utility/static_initializer.h b/src/beast/beast/utility/static_initializer.h deleted file mode 100644 index 99917f19a7..0000000000 --- a/src/beast/beast/utility/static_initializer.h +++ /dev/null @@ -1,258 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UTILITY_STATIC_INITIALIZER_H_INCLUDED -#define BEAST_UTILITY_STATIC_INITIALIZER_H_INCLUDED - -#include -#include - -#ifdef _MSC_VER -#include -#include -#include -#include -#include -#endif - -namespace beast { - -/** Returns an object with static storage duration. - This is a workaround for Visual Studio 2013 and earlier non-thread - safe initialization of function local objects with static storage duration. - - Usage: - @code - my_class& foo() - { - static static_initializer instance; - return *instance; - } - @endcode -*/ -#ifdef _MSC_VER -template < - class T, - class Tag = void -> -class static_initializer -{ -private: - struct data_t - { - // 0 = unconstructed - // 1 = constructing - // 2 = constructed - long volatile state; - - typename std::aligned_storage ::value>::type storage; - }; - - struct destroyer - { - T* t_; - explicit destroyer (T* t) : t_(t) { } - ~destroyer() { t_->~T(); } - }; - - static - data_t& - data() noexcept; - -public: - template - explicit static_initializer (Args&&... args); - - T& - get() noexcept; - - T const& - get() const noexcept - { - return const_cast(*this).get(); - } - - T& - operator*() noexcept - { - return get(); - } - - T const& - operator*() const noexcept - { - return get(); - } - - T* - operator->() noexcept - { - return &get(); - } - - T const* - operator->() const noexcept - { - return &get(); - } -}; - -//------------------------------------------------------------------------------ - -template -auto -static_initializer ::data() noexcept -> - data_t& -{ - static data_t _; // zero-initialized - return _; -} - -template -template -static_initializer ::static_initializer (Args&&... args) -{ - data_t& _(data()); - - // Double Checked Locking Pattern - - if (_.state != 2) - { - T* const t (reinterpret_cast(&_.storage)); - - for(;;) - { - long prev; - prev = _InterlockedCompareExchange(&_.state, 1, 0); - if (prev == 0) - { - try - { - ::new(t) T (std::forward(args)...); - static destroyer on_exit (t); - _InterlockedIncrement(&_.state); - } - catch(...) - { - // Constructors that throw exceptions are unsupported - std::terminate(); - } - } - else if (prev == 1) - { - std::this_thread::yield(); - } - else - { - assert(prev == 2); - break; - } - } - } -} - -template -T& -static_initializer ::get() noexcept -{ - data_t& _(data()); - for(;;) - { - if (_.state == 2) - break; - std::this_thread::yield(); - } - return *reinterpret_cast(&_.storage); -} - -#else -template < - class T, - class Tag = void -> -class static_initializer -{ -private: - T* instance_; - -public: - template - explicit - static_initializer (Args&&... args); - - static_initializer (); - - T& - get() noexcept - { - return *instance_; - } - - T const& - get() const noexcept - { - return const_cast(*this).get(); - } - - T& - operator*() noexcept - { - return get(); - } - - T const& - operator*() const noexcept - { - return get(); - } - - T* - operator->() noexcept - { - return &get(); - } - - T const* - operator->() const noexcept - { - return &get(); - } -}; - -template -static_initializer ::static_initializer () -{ - static T t; - instance_ = &t; -} - -template -template -static_initializer ::static_initializer (Args&&... args) -{ - static T t (std::forward(args)...); - instance_ = &t; -} - -#endif - -} - -#endif diff --git a/src/beast/beast/utility/tagged_integer.h b/src/beast/beast/utility/tagged_integer.h index 49033167c1..fb79a5741f 100644 --- a/src/beast/beast/utility/tagged_integer.h +++ b/src/beast/beast/utility/tagged_integer.h @@ -22,8 +22,6 @@ #include -#include - #include #include #include diff --git a/src/beast/beast/utility/tests/static_initializer.test.cpp b/src/beast/beast/utility/tests/static_initializer.test.cpp deleted file mode 100644 index 61159c3432..0000000000 --- a/src/beast/beast/utility/tests/static_initializer.test.cpp +++ /dev/null @@ -1,209 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include -#include -#include - -namespace beast { - -static_assert(__alignof(long) >= 4, ""); - -class static_initializer_test : public unit_test::suite -{ -public: - // Used to create separate instances for each test - struct cxx11_tag { }; - struct beast_tag { }; - template - struct Case - { - enum { count = N }; - using type = Tag; - }; - - struct Counts - { - Counts() - : calls (0) - , constructed (0) - , access (0) - { - } - - // number of calls to the constructor - std::atomic calls; - - // incremented after construction completes - std::atomic constructed; - - // increment when class is accessed before construction - std::atomic access; - }; - - /* This testing singleton detects two conditions: - 1. Being accessed before getting fully constructed - 2. Getting constructed twice - */ - template - class Test; - - template - static - void - run_many (std::size_t n, Function f); - - template - void - test (cxx11_tag); - - template - void - test (beast_tag); - - template - void - test(); - - void - run (); -}; - -//------------------------------------------------------------------------------ - -template -class static_initializer_test::Test -{ -public: - explicit - Test (Counts& counts); - - void - operator() (Counts& counts); -}; - -template -static_initializer_test::Test::Test (Counts& counts) -{ - ++counts.calls; - std::this_thread::sleep_for (std::chrono::milliseconds (10)); - ++counts.constructed; -} - -template -void -static_initializer_test::Test::operator() (Counts& counts) -{ - if (! counts.constructed) - ++counts.access; -} - -//------------------------------------------------------------------------------ - -template -void -static_initializer_test::run_many (std::size_t n, Function f) -{ - std::atomic start (false); - std::vector threads; - - threads.reserve (n); - - for (auto i (n); i-- ;) - { - threads.emplace_back([&]() - { - while (! start.load()) - std::this_thread::yield(); - f(); - }); - } - std::this_thread::sleep_for (std::chrono::milliseconds (10)); - std::this_thread::yield(); - start.store (true); - for (auto& thread : threads) - thread.join(); -} - -template -void -static_initializer_test::test (cxx11_tag) -{ - testcase << "cxx11 " << Tag::count << " threads"; - - Counts counts; - - run_many (Tag::count, [&]() - { - static Test t (counts); - t(counts); - }); - -#if defined(_MSC_VER) && _MSC_VER < 1900 - // Visual Studio 2013 and earlier can exhibit both double - // construction, and access before construction when function - // local statics are initialized concurrently. - // - expect (counts.constructed > 1 || counts.access > 0); - -#else - expect (counts.constructed == 1 && counts.access == 0); - -#endif -} - -template -void -static_initializer_test::test (beast_tag) -{ - testcase << "beast " << Tag::count << " threads"; - - Counts counts; - - run_many (Tag::count, [&counts]() - { - static static_initializer > t (counts); - (*t)(counts); - }); - - expect (counts.constructed == 1 && counts.access == 0); -} - -template -void -static_initializer_test::test() -{ - test (typename Tag::type {}); -} - -void -static_initializer_test::run () -{ - test > (); - test > (); -} - -//------------------------------------------------------------------------------ - -BEAST_DEFINE_TESTSUITE(static_initializer,utility,beast); - -} diff --git a/src/ripple/app/tx/impl/BookTip.h b/src/ripple/app/tx/impl/BookTip.h index 1d127095be..0193493759 100644 --- a/src/ripple/app/tx/impl/BookTip.h +++ b/src/ripple/app/tx/impl/BookTip.h @@ -23,7 +23,6 @@ #include #include #include -#include #include diff --git a/src/ripple/app/tx/impl/Offer.h b/src/ripple/app/tx/impl/Offer.h index 4d3bd4c5cd..c0d88ac12a 100644 --- a/src/ripple/app/tx/impl/Offer.h +++ b/src/ripple/app/tx/impl/Offer.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include diff --git a/src/ripple/app/tx/impl/OfferStream.h b/src/ripple/app/tx/impl/OfferStream.h index 47b6c62834..955b7f7677 100644 --- a/src/ripple/app/tx/impl/OfferStream.h +++ b/src/ripple/app/tx/impl/OfferStream.h @@ -25,7 +25,6 @@ #include #include #include -#include namespace ripple { diff --git a/src/ripple/app/tx/impl/Taker.h b/src/ripple/app/tx/impl/Taker.h index b3808651d7..e6db449976 100644 --- a/src/ripple/app/tx/impl/Taker.h +++ b/src/ripple/app/tx/impl/Taker.h @@ -27,7 +27,6 @@ #include #include #include -#include #include namespace ripple { diff --git a/src/ripple/basics/Buffer.h b/src/ripple/basics/Buffer.h index 7b8d4bcfb2..f60ad296f0 100644 --- a/src/ripple/basics/Buffer.h +++ b/src/ripple/basics/Buffer.h @@ -21,7 +21,6 @@ #define RIPPLE_BASICS_BUFFER_H_INCLUDED #include -#include #include #include #include diff --git a/src/ripple/basics/CountedObject.h b/src/ripple/basics/CountedObject.h index e2ada44583..6329997fb3 100644 --- a/src/ripple/basics/CountedObject.h +++ b/src/ripple/basics/CountedObject.h @@ -20,8 +20,6 @@ #ifndef RIPPLE_BASICS_COUNTEDOBJECT_H_INCLUDED #define RIPPLE_BASICS_COUNTEDOBJECT_H_INCLUDED -#include -#include #include #include #include @@ -136,8 +134,8 @@ private: private: static Counter& getCounter() { - static beast::static_initializer c; - return *c; + static Counter c; + return c; } }; diff --git a/src/ripple/basics/Log.h b/src/ripple/basics/Log.h index aaee88f389..7ed1800fad 100644 --- a/src/ripple/basics/Log.h +++ b/src/ripple/basics/Log.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/basics/RangeSet.h b/src/ripple/basics/RangeSet.h index b20c558a0a..fbbaf5677b 100644 --- a/src/ripple/basics/RangeSet.h +++ b/src/ripple/basics/RangeSet.h @@ -20,7 +20,6 @@ #ifndef RIPPLE_BASICS_RANGESET_H_INCLUDED #define RIPPLE_BASICS_RANGESET_H_INCLUDED -#include #include #include #include diff --git a/src/ripple/basics/Slice.h b/src/ripple/basics/Slice.h index 02db04e8db..abf0863c7d 100644 --- a/src/ripple/basics/Slice.h +++ b/src/ripple/basics/Slice.h @@ -21,7 +21,6 @@ #define RIPPLE_BASICS_SLICE_H_INCLUDED #include -#include #include #include #include diff --git a/src/ripple/basics/contract.h b/src/ripple/basics/contract.h index 9b65e826c3..adfac50a15 100644 --- a/src/ripple/basics/contract.h +++ b/src/ripple/basics/contract.h @@ -34,9 +34,6 @@ namespace ripple { namespace detail { -void -accessViolation(); - void throwException( std::exception_ptr ep); @@ -54,9 +51,10 @@ Throw (Args&&... args) } /** Called when faulty logic causes a broken invariant. */ +[[noreturn]] void LogicError ( - std::string const& how); + std::string const& how) noexcept; /** Called to throw an exception. */ #ifndef THROW diff --git a/src/ripple/basics/hardened_hash.h b/src/ripple/basics/hardened_hash.h index 188afe793f..11a61c726f 100644 --- a/src/ripple/basics/hardened_hash.h +++ b/src/ripple/basics/hardened_hash.h @@ -24,8 +24,6 @@ #include #include // #include // -#include -#include #include #include @@ -66,9 +64,9 @@ make_seed_pair() noexcept // state_t(state_t const&) = delete; // state_t& operator=(state_t const&) = delete; }; - static beast::static_initializer state; - std::lock_guard lock (state->mutex); - return {state->dist(state->gen), state->dist(state->gen)}; + static state_t state; + std::lock_guard lock (state.mutex); + return {state.dist(state.gen), state.dist(state.gen)}; } } @@ -87,10 +85,8 @@ private: detail::seed_pair const& init_seed_pair() { - static beast::static_initializer const p ( - detail::make_seed_pair<>()); - return *p; + static detail::seed_pair const p = detail::make_seed_pair<>(); + return p; } public: diff --git a/src/ripple/basics/impl/contract.cpp b/src/ripple/basics/impl/contract.cpp index 80c49d046d..d30f969f31 100644 --- a/src/ripple/basics/impl/contract.cpp +++ b/src/ripple/basics/impl/contract.cpp @@ -19,18 +19,21 @@ #include #include +#include +#include namespace ripple { namespace detail { +[[noreturn]] void -accessViolation() +accessViolation() noexcept { - // dereference memory - // location zero + // dereference memory location zero int volatile* j = 0; (void)*j; + std::abort (); } // This hook lets you do pre or post @@ -43,8 +46,9 @@ throwException (std::exception_ptr ep) } // detail +[[noreturn]] void -LogicError (std::string const&) +LogicError (std::string const&) noexcept { detail::accessViolation(); } diff --git a/src/ripple/basics/impl/make_SSLContext.cpp b/src/ripple/basics/impl/make_SSLContext.cpp index 5595c22deb..1615c1344d 100644 --- a/src/ripple/basics/impl/make_SSLContext.cpp +++ b/src/ripple/basics/impl/make_SSLContext.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -323,9 +322,7 @@ disallowRenegotiation (SSL const* ssl, bool isNew) // Do not allow a connection to renegotiate // more than once every 4 minutes - static beast::static_initializer static_data; - - auto& sd (static_data.get ()); + static StaticData sd; std::lock_guard lock (sd.lock); auto const expired (sd.set.clock().now() - std::chrono::minutes(4)); diff --git a/src/ripple/basics/make_SSLContext.h b/src/ripple/basics/make_SSLContext.h index e22948f437..c43b3be654 100644 --- a/src/ripple/basics/make_SSLContext.h +++ b/src/ripple/basics/make_SSLContext.h @@ -21,7 +21,6 @@ #define RIPPLE_BASICS_MAKE_SSLCONTEXT_H_INCLUDED #include -#include #include namespace ripple { diff --git a/src/ripple/crypto/Base58Data.h b/src/ripple/crypto/Base58Data.h index 2caa782062..7637db7466 100644 --- a/src/ripple/crypto/Base58Data.h +++ b/src/ripple/crypto/Base58Data.h @@ -51,10 +51,8 @@ protected: ~CBase58Data (); CBase58Data (CBase58Data const&) = default; CBase58Data& operator= (CBase58Data const&) = default; -#ifndef _MSC_VER CBase58Data (CBase58Data&&) = default; CBase58Data& operator= (CBase58Data&&) = default; -#endif void SetData (int version, Blob const& vchDataIn) { diff --git a/src/ripple/json/Object.h b/src/ripple/json/Object.h index 3adcf44698..827d29745f 100644 --- a/src/ripple/json/Object.h +++ b/src/ripple/json/Object.h @@ -318,13 +318,7 @@ public: { } -#ifdef _MSC_VER - WriterObject (WriterObject&& other) noexcept - : writer_ (std::move (other.writer_)), - object_ (std::move (other.object_)) - { - } -#endif + WriterObject (WriterObject&& other) = default; Object* operator->() { diff --git a/src/ripple/ledger/ApplyViewImpl.h b/src/ripple/ledger/ApplyViewImpl.h index 668ccc649b..bd3554d694 100644 --- a/src/ripple/ledger/ApplyViewImpl.h +++ b/src/ripple/ledger/ApplyViewImpl.h @@ -43,16 +43,7 @@ public: ApplyViewImpl& operator= (ApplyViewImpl&&) = delete; ApplyViewImpl& operator= (ApplyViewImpl const&) = delete; -#ifdef _MSC_VER - ApplyViewImpl (ApplyViewImpl&& other) - : ApplyViewBase (std::move(other)) - , deliver_ (std::move(other.deliver_)) - { - } -#else ApplyViewImpl (ApplyViewImpl&&) = default; -#endif - ApplyViewImpl( ReadView const* base, ApplyFlags flags); diff --git a/src/ripple/ledger/OpenView.h b/src/ripple/ledger/OpenView.h index f5eeeafb3a..4865a38203 100644 --- a/src/ripple/ledger/OpenView.h +++ b/src/ripple/ledger/OpenView.h @@ -67,21 +67,7 @@ public: OpenView& operator= (OpenView&&) = delete; OpenView& operator= (OpenView const&) = delete; -#ifdef _MSC_VER - OpenView (OpenView&& other) - : ReadView (std::move(other)) - , TxsRawView (std::move(other)) - , rules_ (std::move(other.rules_)) - , txs_ (std::move(other.txs_)) - , info_ (std::move(other.info_)) - , base_ (std::move(other.base_)) - , items_ (std::move(other.items_)) - , hold_ (std::move(other.hold_)) - { - } -#else OpenView (OpenView&&) = default; -#endif /** Construct a shallow copy. diff --git a/src/ripple/ledger/PaymentSandbox.h b/src/ripple/ledger/PaymentSandbox.h index b1fc17a69a..cdf989d178 100644 --- a/src/ripple/ledger/PaymentSandbox.h +++ b/src/ripple/ledger/PaymentSandbox.h @@ -96,16 +96,7 @@ public: PaymentSandbox& operator= (PaymentSandbox&&) = delete; PaymentSandbox& operator= (PaymentSandbox const&) = delete; -#ifdef _MSC_VER - PaymentSandbox (PaymentSandbox&& other) - : ApplyViewBase (std::move(other)) - , tab_ (std::move(other.tab_)) - , ps_ (std::move(other.ps_)) - { - } -#else PaymentSandbox (PaymentSandbox&&) = default; -#endif PaymentSandbox (ReadView const* base, ApplyFlags flags) : ApplyViewBase (base, flags) diff --git a/src/ripple/ledger/Sandbox.h b/src/ripple/ledger/Sandbox.h index 3712059728..36f6c9e6bf 100644 --- a/src/ripple/ledger/Sandbox.h +++ b/src/ripple/ledger/Sandbox.h @@ -40,14 +40,7 @@ public: Sandbox& operator= (Sandbox&&) = delete; Sandbox& operator= (Sandbox const&) = delete; -#ifdef _MSC_VER - Sandbox (Sandbox&& other) - : ApplyViewBase (std::move(other)) - { - } -#else Sandbox (Sandbox&&) = default; -#endif Sandbox (ReadView const* base, ApplyFlags flags) : ApplyViewBase (base, flags) diff --git a/src/ripple/ledger/detail/ApplyStateTable.h b/src/ripple/ledger/detail/ApplyStateTable.h index 83a34e14d2..dd978f59f1 100644 --- a/src/ripple/ledger/detail/ApplyStateTable.h +++ b/src/ripple/ledger/detail/ApplyStateTable.h @@ -55,20 +55,12 @@ private: public: ApplyStateTable() = default; + ApplyStateTable (ApplyStateTable&&) = default; + ApplyStateTable (ApplyStateTable const&) = delete; ApplyStateTable& operator= (ApplyStateTable&&) = delete; ApplyStateTable& operator= (ApplyStateTable const&) = delete; -#ifdef _MSC_VER - ApplyStateTable (ApplyStateTable&& other) - : items_ (std::move(other.items_)) - , dropsDestroyed_ (std::move(other.dropsDestroyed_)) - { - } -#else - ApplyStateTable (ApplyStateTable&&) = default; -#endif - void apply (RawView& to) const; diff --git a/src/ripple/ledger/detail/ApplyViewBase.h b/src/ripple/ledger/detail/ApplyViewBase.h index 139e707cde..0a60389f8d 100644 --- a/src/ripple/ledger/detail/ApplyViewBase.h +++ b/src/ripple/ledger/detail/ApplyViewBase.h @@ -39,19 +39,8 @@ public: ApplyViewBase& operator= (ApplyViewBase&&) = delete; ApplyViewBase& operator= (ApplyViewBase const&) = delete; -#ifdef _MSC_VER - ApplyViewBase (ApplyViewBase&& other) - : ApplyView (std::move(other)) - , RawView (std::move(other)) - , flags_ (std::move(other.flags_)) - , base_ (std::move(other.base_)) - , items_ (std::move(other.items_)) - , dropsDestroyed_ (std::move(other.dropsDestroyed_)) - { - } -#else + ApplyViewBase (ApplyViewBase&&) = default; -#endif ApplyViewBase( ReadView const* base, ApplyFlags flags); diff --git a/src/ripple/ledger/detail/RawStateTable.h b/src/ripple/ledger/detail/RawStateTable.h index 7ba75b66cc..973e19e256 100644 --- a/src/ripple/ledger/detail/RawStateTable.h +++ b/src/ripple/ledger/detail/RawStateTable.h @@ -36,19 +36,11 @@ public: RawStateTable() = default; RawStateTable (RawStateTable const&) = default; + RawStateTable (RawStateTable&&) = default; + RawStateTable& operator= (RawStateTable&&) = delete; RawStateTable& operator= (RawStateTable const&) = delete; -#ifdef _MSC_VER - RawStateTable (RawStateTable&& other) - : items_ (std::move(other.items_)) - , dropsDestroyed_ (std::move(other.dropsDestroyed_)) - { - } -#else - RawStateTable (RawStateTable&&) = default; -#endif - void apply (RawView& to) const; diff --git a/src/ripple/ledger/tests/PathSet.h b/src/ripple/ledger/tests/PathSet.h index 30f83f5a70..a21ec7c41d 100644 --- a/src/ripple/ledger/tests/PathSet.h +++ b/src/ripple/ledger/tests/PathSet.h @@ -55,20 +55,9 @@ public: Path () = default; Path (Path const&) = default; Path& operator=(Path const&) = default; - -#ifdef _MSC_VER - Path (Path&& rhs) : path (std::move (rhs.path)) - { - } - Path& operator=(Path&& rhs) - { - path = std::move (rhs.path); - return *this; - } -#else Path (Path&&) = default; Path& operator=(Path&&) = default; -#endif + template explicit Path (First&& first, Rest&&... rest) { @@ -118,20 +107,9 @@ public: PathSet () = default; PathSet (PathSet const&) = default; PathSet& operator=(PathSet const&) = default; - -#ifdef _MSC_VER - PathSet (PathSet&& rhs) : paths (std::move (rhs.paths)) - { - } - PathSet& operator=(PathSet&& rhs) - { - paths = std::move (rhs.paths); - return *this; - } -#else PathSet (PathSet&&) = default; PathSet& operator=(PathSet&&) = default; -#endif + template explicit PathSet (First&& first, Rest&&... rest) { diff --git a/src/ripple/nodestore/impl/EncodedBlob.h b/src/ripple/nodestore/impl/EncodedBlob.h index ec5ad5692a..67911917ed 100644 --- a/src/ripple/nodestore/impl/EncodedBlob.h +++ b/src/ripple/nodestore/impl/EncodedBlob.h @@ -22,7 +22,6 @@ #include #include -#include #include namespace ripple { diff --git a/src/ripple/nodestore/impl/ManagerImp.cpp b/src/ripple/nodestore/impl/ManagerImp.cpp index f4e9e4cef5..c1a0afda90 100644 --- a/src/ripple/nodestore/impl/ManagerImp.cpp +++ b/src/ripple/nodestore/impl/ManagerImp.cpp @@ -32,8 +32,8 @@ namespace NodeStore { ManagerImp& ManagerImp::instance() { - static beast::static_initializer _; - return _.get(); + static ManagerImp _; + return _; } void diff --git a/src/ripple/overlay/impl/Manifest.h b/src/ripple/overlay/impl/Manifest.h index 9412a0a607..75f2943ebb 100644 --- a/src/ripple/overlay/impl/Manifest.h +++ b/src/ripple/overlay/impl/Manifest.h @@ -92,27 +92,8 @@ struct Manifest Manifest(std::string s, PublicKey pk, PublicKey spk, std::uint32_t seq); -#ifdef _MSC_VER - Manifest(Manifest&& other) - : serialized(std::move(other.serialized)) - , masterKey(std::move(other.masterKey)) - , signingKey(std::move(other.signingKey)) - , sequence(other.sequence) - { - } - - Manifest& operator=(Manifest&& other) - { - serialized = std::move(other.serialized); - masterKey = std::move(other.masterKey); - signingKey = std::move(other.signingKey); - sequence = other.sequence; - return *this; - } -#else Manifest(Manifest&& other) = default; Manifest& operator=(Manifest&& other) = default; -#endif bool verify () const; uint256 hash () const; @@ -149,22 +130,9 @@ private: struct MappedType { MappedType() = default; -#ifdef _MSC_VER - MappedType(MappedType&& rhs) - :comment (std::move (rhs.comment)) - , m (std::move (rhs.m)) - { - } - MappedType& operator=(MappedType&& rhs) - { - comment = std::move (rhs.comment); - m = std::move (rhs.m); - return *this; - } -#else MappedType(MappedType&&) = default; MappedType& operator=(MappedType&&) = default; -#endif + MappedType(std::string comment, std::string serialized, PublicKey pk, PublicKey spk, std::uint32_t seq) diff --git a/src/ripple/overlay/impl/TMHello.cpp b/src/ripple/overlay/impl/TMHello.cpp index cbb68ee372..74036b2ecf 100644 --- a/src/ripple/overlay/impl/TMHello.cpp +++ b/src/ripple/overlay/impl/TMHello.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -197,7 +196,7 @@ appendHello (beast::http::message& m, std::vector parse_ProtocolVersions (std::string const& s) { - static beast::static_initializer re ( + static boost::regex re ( "^" // start of line "RTXP/" // the string "RTXP/" "([1-9][0-9]*)" // a number (non-zero and with no leading zeroes) @@ -211,7 +210,7 @@ parse_ProtocolVersions (std::string const& s) for (auto const& s : list) { boost::smatch m; - if (! boost::regex_match (s, m, *re)) + if (! boost::regex_match (s, m, re)) continue; int major; int minor; diff --git a/src/ripple/protocol/HashPrefix.h b/src/ripple/protocol/HashPrefix.h index a20472818a..686ff0531a 100644 --- a/src/ripple/protocol/HashPrefix.h +++ b/src/ripple/protocol/HashPrefix.h @@ -21,7 +21,6 @@ #define RIPPLE_PROTOCOL_HASHPREFIX_H_INCLUDED #include -#include #include namespace ripple { diff --git a/src/ripple/protocol/IOUAmount.h b/src/ripple/protocol/IOUAmount.h index 3be6a58a3f..54818e864e 100644 --- a/src/ripple/protocol/IOUAmount.h +++ b/src/ripple/protocol/IOUAmount.h @@ -20,7 +20,6 @@ #ifndef RIPPLE_PROTOCOL_IOUAMOUNT_H_INCLUDED #define RIPPLE_PROTOCOL_IOUAMOUNT_H_INCLUDED -#include #include #include #include diff --git a/src/ripple/protocol/PublicKey.h b/src/ripple/protocol/PublicKey.h index aea5939b9c..a9f80d1bd2 100644 --- a/src/ripple/protocol/PublicKey.h +++ b/src/ripple/protocol/PublicKey.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/protocol/Quality.h b/src/ripple/protocol/Quality.h index 1ed9b42de2..60b564a0d1 100644 --- a/src/ripple/protocol/Quality.h +++ b/src/ripple/protocol/Quality.h @@ -21,7 +21,6 @@ #define RIPPLE_PROTOCOL_QUALITY_H_INCLUDED #include -#include #include #include diff --git a/src/ripple/protocol/Rate.h b/src/ripple/protocol/Rate.h index 3a31d79aa1..b7268d6979 100644 --- a/src/ripple/protocol/Rate.h +++ b/src/ripple/protocol/Rate.h @@ -21,7 +21,6 @@ #define RIPPLE_PROTOCOL_RATE_H_INCLUDED #include -#include #include #include #include diff --git a/src/ripple/protocol/RippleAddress.h b/src/ripple/protocol/RippleAddress.h index 0996ff1284..bbc8983e96 100644 --- a/src/ripple/protocol/RippleAddress.h +++ b/src/ripple/protocol/RippleAddress.h @@ -29,7 +29,6 @@ #include #include #include -#include namespace ripple { diff --git a/src/ripple/protocol/SField.h b/src/ripple/protocol/SField.h index be25a4dd68..c31c1fb9b6 100644 --- a/src/ripple/protocol/SField.h +++ b/src/ripple/protocol/SField.h @@ -144,26 +144,11 @@ public: int fieldMeta; int fieldNum; IsSigning const signingField; - std::string rawJsonName; - Json::StaticString jsonName; + std::string jsonName; SField(SField const&) = delete; SField& operator=(SField const&) = delete; -#ifndef _MSC_VER SField(SField&&) = default; -#else // remove this when VS gets defaulted move members - SField(SField&& sf) - : fieldCode (std::move(sf.fieldCode)) - , fieldType (std::move(sf.fieldType)) - , fieldValue (std::move(sf.fieldValue)) - , fieldName (std::move(sf.fieldName)) - , fieldMeta (std::move(sf.fieldMeta)) - , fieldNum (std::move(sf.fieldNum)) - , signingField (std::move(sf.signingField)) - , rawJsonName (std::move(sf.rawJsonName)) - , jsonName (rawJsonName.c_str ()) - {} -#endif protected: // These constructors can only be called from FieldNames.cpp @@ -191,7 +176,7 @@ public: return !fieldName.empty (); } - Json::StaticString const& getJsonName () const + std::string const& getJsonName () const { return jsonName; } diff --git a/src/ripple/protocol/STObject.h b/src/ripple/protocol/STObject.h index b6eeb51ec2..f5758e46df 100644 --- a/src/ripple/protocol/STObject.h +++ b/src/ripple/protocol/STObject.h @@ -35,7 +35,6 @@ #include #include -#include #include #include diff --git a/src/ripple/protocol/Serializer.h b/src/ripple/protocol/Serializer.h index 4ae3682e2f..3fc1ce5e10 100644 --- a/src/ripple/protocol/Serializer.h +++ b/src/ripple/protocol/Serializer.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/protocol/XRPAmount.h b/src/ripple/protocol/XRPAmount.h index 9c6e0afb66..ae964f8b60 100644 --- a/src/ripple/protocol/XRPAmount.h +++ b/src/ripple/protocol/XRPAmount.h @@ -21,7 +21,6 @@ #define RIPPLE_PROTOCOL_XRPAMOUNT_H_INCLUDED #include -#include #include #include #include diff --git a/src/ripple/protocol/digest.h b/src/ripple/protocol/digest.h index e15be3a894..20d42f8999 100644 --- a/src/ripple/protocol/digest.h +++ b/src/ripple/protocol/digest.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include diff --git a/src/ripple/protocol/impl/Indexes.cpp b/src/ripple/protocol/impl/Indexes.cpp index 95cdeea010..a10071c979 100644 --- a/src/ripple/protocol/impl/Indexes.cpp +++ b/src/ripple/protocol/impl/Indexes.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include namespace ripple { @@ -135,9 +134,9 @@ getQualityIndex (uint256 const& uBase, const std::uint64_t uNodeDir) uint256 getQualityNext (uint256 const& uBase) { - static beast::static_initializer const uNext ( + static uint256 const uNext ( from_hex_text("10000000000000000")); - return uBase + *uNext; + return uBase + uNext; } std::uint64_t diff --git a/src/ripple/protocol/impl/PublicKey.cpp b/src/ripple/protocol/impl/PublicKey.cpp index b3929258bc..4d29db2b7c 100644 --- a/src/ripple/protocol/impl/PublicKey.cpp +++ b/src/ripple/protocol/impl/PublicKey.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include // diff --git a/src/ripple/protocol/impl/SField.cpp b/src/ripple/protocol/impl/SField.cpp index 14deba7731..5bc60f605b 100644 --- a/src/ripple/protocol/impl/SField.cpp +++ b/src/ripple/protocol/impl/SField.cpp @@ -257,8 +257,7 @@ SField::SField (SerializedTypeID tid, int fv, const char* fn, , fieldMeta (meta) , fieldNum (++num) , signingField (signing) - , rawJsonName (getName ()) - , jsonName (rawJsonName.c_str ()) + , jsonName (getName ()) { } @@ -269,8 +268,7 @@ SField::SField (int fc) , fieldMeta (sMD_Never) , fieldNum (++num) , signingField (IsSigning::yes) - , rawJsonName (getName ()) - , jsonName (rawJsonName.c_str ()) + , jsonName (getName ()) { } @@ -278,15 +276,15 @@ SField::SField (int fc) // This is naturally done with no extra expense // from getField(int code). SField::SField (SerializedTypeID tid, int fv) - : fieldCode (field_code (tid, fv)), fieldType (tid), fieldValue (fv), - fieldMeta (sMD_Default), - fieldNum (++num), - signingField (IsSigning::yes), - jsonName (nullptr) + : fieldCode (field_code (tid, fv)) + , fieldType (tid) + , fieldValue (fv) + , fieldMeta (sMD_Default) + , fieldNum (++num) + , signingField (IsSigning::yes) { fieldName = std::to_string (tid) + '/' + std::to_string (fv); - rawJsonName = getName (); - jsonName = Json::StaticString (rawJsonName.c_str ()); + jsonName = getName (); assert ((fv != 1) || ((tid != STI_ARRAY) && (tid != STI_OBJECT))); } diff --git a/src/ripple/protocol/impl/STObject.cpp b/src/ripple/protocol/impl/STObject.cpp index 4309765333..5d52f498f9 100644 --- a/src/ripple/protocol/impl/STObject.cpp +++ b/src/ripple/protocol/impl/STObject.cpp @@ -37,8 +37,8 @@ STObject::~STObject() { #if 0 // Turn this on to get a histogram on exit - static beast::static_initializer log; - (*log)(v_.size()); + static Log log; + log(v_.size()); #endif } diff --git a/src/ripple/protocol/impl/STVar.h b/src/ripple/protocol/impl/STVar.h index e20bf8a37f..e696948ffe 100644 --- a/src/ripple/protocol/impl/STVar.h +++ b/src/ripple/protocol/impl/STVar.h @@ -29,7 +29,6 @@ #include #include -#include #include #include diff --git a/src/ripple/protocol/impl/SecretKey.cpp b/src/ripple/protocol/impl/SecretKey.cpp index dfc4047163..2db6628596 100644 --- a/src/ripple/protocol/impl/SecretKey.cpp +++ b/src/ripple/protocol/impl/SecretKey.cpp @@ -124,9 +124,6 @@ sign (PublicKey const& pk, sk.data(), pk.data() + 1, b.data()); return b; } - default: - // VFALCO Work-around for missing msvc [[noreturn]] - LogicError("sign: invalid type"); case KeyType::secp256k1: { sha512_half_hasher h; @@ -144,6 +141,8 @@ sign (PublicKey const& pk, LogicError("sign: secp256k1_ecdsa_sign failed"); return Buffer(sig, siglen); } + default: + LogicError("sign: invalid type"); } } @@ -209,9 +208,6 @@ derivePublicKey (KeyType type, SecretKey const& sk) return PublicKey(Slice{ buf, static_cast(len) }); } - default: - // VFALCO Work-around for missing msvc [[noreturn]] - LogicError("derivePublicKey: bad key type"); case KeyType::ed25519: { unsigned char buf[33]; @@ -219,6 +215,8 @@ derivePublicKey (KeyType type, SecretKey const& sk) ed25519_publickey(sk.data(), &buf[1]); return PublicKey(Slice{ buf, sizeof(buf) }); } + default: + LogicError("derivePublicKey: bad key type"); }; } diff --git a/src/ripple/protocol/impl/TxFormats.cpp b/src/ripple/protocol/impl/TxFormats.cpp index bfbf6af068..6ca6a66f41 100644 --- a/src/ripple/protocol/impl/TxFormats.cpp +++ b/src/ripple/protocol/impl/TxFormats.cpp @@ -18,7 +18,6 @@ //============================================================================== #include -#include #include namespace ripple { @@ -139,9 +138,8 @@ void TxFormats::addCommonFields (Item& item) TxFormats const& TxFormats::getInstance () { - static beast::static_initializer< - TxFormats> instance; - return *instance; + static TxFormats const instance; + return instance; } } // ripple diff --git a/src/ripple/protocol/impl/UintTypes.cpp b/src/ripple/protocol/impl/UintTypes.cpp index 7088144780..fb349a78a4 100644 --- a/src/ripple/protocol/impl/UintTypes.cpp +++ b/src/ripple/protocol/impl/UintTypes.cpp @@ -23,7 +23,6 @@ #include #include #include -#include namespace ripple { @@ -43,10 +42,10 @@ std::string to_string(Currency const& currency) if (currency == noCurrency()) return "1"; - static beast::static_initializer const sIsoBits ( + static Currency const sIsoBits ( from_hex_text("FFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFF")); - if ((currency & *sIsoBits).isZero ()) + if ((currency & sIsoBits).isZero ()) { // The offset of the 3 character ISO code in the currency descriptor int const isoOffset = 12; diff --git a/src/ripple/protocol/impl/secp256k1.h b/src/ripple/protocol/impl/secp256k1.h index 7924de363c..92870601bf 100644 --- a/src/ripple/protocol/impl/secp256k1.h +++ b/src/ripple/protocol/impl/secp256k1.h @@ -20,7 +20,6 @@ #ifndef RIPPLE_PROTOCOL_SECP256K1_H_INCLUDED #define RIPPLE_PROTOCOL_SECP256K1_H_INCLUDED -#include #include namespace ripple { @@ -44,8 +43,8 @@ secp256k1Context() secp256k1_context_destroy(impl); } }; - static beast::static_initializer const h; - return h->impl; + static holder const h; + return h.impl; } inline diff --git a/src/ripple/rpc/handlers/AccountObjects.cpp b/src/ripple/rpc/handlers/AccountObjects.cpp index e767feff37..1dd41fc887 100644 --- a/src/ripple/rpc/handlers/AccountObjects.cpp +++ b/src/ripple/rpc/handlers/AccountObjects.cpp @@ -79,30 +79,29 @@ Json::Value doAccountObjects (RPC::Context& context) auto type = ltINVALID; if (params.isMember (jss::type)) { - using filter_types = std::vector >; static - beast::static_initializer const types ([]() -> filter_types { - return { - { "account", ltACCOUNT_ROOT }, - { "amendments", ltAMENDMENTS }, - { "directory", ltDIR_NODE }, - { "fee", ltFEE_SETTINGS }, - { "hashes", ltLEDGER_HASHES }, - { "offer", ltOFFER }, - { "state", ltRIPPLE_STATE }, - { "ticket", ltTICKET } - }; - }()); + std::vector> const + types + { + { "account", ltACCOUNT_ROOT }, + { "amendments", ltAMENDMENTS }, + { "directory", ltDIR_NODE }, + { "fee", ltFEE_SETTINGS }, + { "hashes", ltLEDGER_HASHES }, + { "offer", ltOFFER }, + { "state", ltRIPPLE_STATE }, + { "ticket", ltTICKET } + }; auto const& p = params[jss::type]; if (! p.isString ()) return RPC::expected_field_error (jss::type, "string"); auto const filter = p.asString (); - auto iter = std::find_if (types->begin (), types->end (), - [&filter](decltype (types->front ())& t) + auto iter = std::find_if (types.begin (), types.end (), + [&filter](decltype (types.front ())& t) { return t.first == filter; }); - if (iter == types->end ()) + if (iter == types.end ()) return RPC::invalid_field_error (jss::type); type = iter->second; diff --git a/src/ripple/rpc/impl/Handler.cpp b/src/ripple/rpc/impl/Handler.cpp index e0721816f7..f50521df95 100644 --- a/src/ripple/rpc/impl/Handler.cpp +++ b/src/ripple/rpc/impl/Handler.cpp @@ -165,8 +165,8 @@ Handler handlerArray[] { } // namespace const Handler* getHandler(std::string const& name) { - static beast::static_initializer const handlers(handlerArray); - return handlers->getHandler(name); + static HandlerTable const handlers(handlerArray); + return handlers.getHandler(name); } } // RPC diff --git a/src/ripple/shamap/impl/SHAMapNodeID.cpp b/src/ripple/shamap/impl/SHAMapNodeID.cpp index bacbe95c2f..cdcbd0ce1a 100644 --- a/src/ripple/shamap/impl/SHAMapNodeID.cpp +++ b/src/ripple/shamap/impl/SHAMapNodeID.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -53,8 +52,8 @@ SHAMapNodeID::Masks (int depth) entry[mask_size-1] = selector; } }; - static beast::static_initializer masks; - return masks->entry[depth]; + static masks_t const masks; + return masks.entry[depth]; } // canonicalize the hash to a node ID for this depth diff --git a/src/ripple/test/jtx/Account.h b/src/ripple/test/jtx/Account.h index a95d1d43e7..70de0ef1a5 100644 --- a/src/ripple/test/jtx/Account.h +++ b/src/ripple/test/jtx/Account.h @@ -23,7 +23,6 @@ #include #include #include -#include #include namespace ripple { @@ -46,7 +45,6 @@ public: Account() = default; Account (Account const&) = default; Account& operator= (Account const&) = default; - Account (Account&&) = default; Account& operator= (Account&&) = default; diff --git a/src/ripple/test/jtx/JTx.h b/src/ripple/test/jtx/JTx.h index a9e62c7d7d..ea1dde02ee 100644 --- a/src/ripple/test/jtx/JTx.h +++ b/src/ripple/test/jtx/JTx.h @@ -50,36 +50,10 @@ struct JTx std::function signer; JTx() = default; - -#if defined(_MSC_VER) && _MSC_VER <= 1800 - JTx(JTx&& other) - : jv(std::move(other.jv)) - , requires(std::move(other.requires)) - , ter(std::move(other.ter)) - , fill_fee(std::move(other.fill_fee)) - , fill_seq(std::move(other.fill_seq)) - , fill_sig(std::move(other.fill_sig)) - , stx(std::move(other.stx)) - , signer(std::move(other.signer)) - , props_(std::move(other.props_)) - { - } - - JTx& operator=(JTx&& other) noexcept - { - jv = std::move(other.jv); - requires = std::move(other.requires); - ter = std::move(other.ter); - fill_fee = std::move(other.fill_fee); - fill_seq = std::move(other.fill_seq); - fill_sig = std::move(other.fill_sig); - stx = std::move(other.stx); - signer = std::move(other.signer); - props_ = std::move(other.props_); - - return *this; - } -#endif + JTx (JTx const&) = default; + JTx& operator=(JTx const&) = default; + JTx(JTx&&) = default; + JTx& operator=(JTx&&) = default; JTx (Json::Value&& jv_) : jv(std::move(jv_)) @@ -184,21 +158,8 @@ private: return *this; } - #if defined(_MSC_VER) && _MSC_VER <= 1800 - prop_list(prop_list&& other) - : list(std::move(other.list)) - { - } - - prop_list& operator=(prop_list&& other) - { - list = std::move(other.list); - return *this; - } - #else prop_list(prop_list&& src) = default; prop_list& operator=(prop_list&& src) = default; - #endif std::vector> list; diff --git a/src/ripple/unl/tests/qalloc.h b/src/ripple/unl/tests/qalloc.h index a94336ebdf..85ddd1c7d8 100644 --- a/src/ripple/unl/tests/qalloc.h +++ b/src/ripple/unl/tests/qalloc.h @@ -57,7 +57,7 @@ private: void* allocate (std::size_t bytes, std::size_t align); - + bool deallocate(); }; @@ -113,10 +113,8 @@ public: qalloc_type (qalloc_type const&) = default; qalloc_type& operator= (qalloc_type const&) = default; -#ifndef _MSC_VER qalloc_type (qalloc_type&& other) = default; qalloc_type& operator= (qalloc_type&&) = default; -#endif qalloc_type();