mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-21 19:32:34 +00:00
Compare commits
3 Commits
ximinez/fi
...
a1q123456/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61ce2651d3 | ||
|
|
486a3a57b8 | ||
|
|
00632c636c |
27
.clang-tidy
27
.clang-tidy
@@ -97,21 +97,9 @@ Checks: "-*,
|
||||
misc-throw-by-value-catch-by-reference,
|
||||
misc-unused-alias-decls,
|
||||
misc-unused-using-decls,
|
||||
modernize-concat-nested-namespaces,
|
||||
modernize-deprecated-headers,
|
||||
modernize-make-shared,
|
||||
modernize-make-unique,
|
||||
modernize-pass-by-value,
|
||||
modernize-type-traits,
|
||||
modernize-use-designated-initializers,
|
||||
modernize-use-emplace,
|
||||
modernize-use-equals-default,
|
||||
modernize-use-equals-delete,
|
||||
modernize-use-override,
|
||||
modernize-use-ranges,
|
||||
modernize-use-starts-ends-with,
|
||||
modernize-use-std-numbers,
|
||||
modernize-use-using,
|
||||
modernize-deprecated-headers,
|
||||
llvm-namespace-comment,
|
||||
performance-faster-string-find,
|
||||
performance-for-range-copy,
|
||||
@@ -153,6 +141,19 @@ Checks: "-*,
|
||||
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names
|
||||
# readability-static-accessed-through-instance, # this check is probably unnecessary. it makes the code less readable
|
||||
# readability-identifier-naming, # https://github.com/XRPLF/rippled/pull/6571
|
||||
#
|
||||
# modernize-concat-nested-namespaces,
|
||||
# modernize-pass-by-value,
|
||||
# modernize-type-traits,
|
||||
# modernize-use-designated-initializers,
|
||||
# modernize-use-emplace,
|
||||
# modernize-use-equals-default,
|
||||
# modernize-use-equals-delete,
|
||||
# modernize-use-override,
|
||||
# modernize-use-ranges,
|
||||
# modernize-use-starts-ends-with,
|
||||
# modernize-use-std-numbers,
|
||||
# modernize-use-using,
|
||||
# ---
|
||||
#
|
||||
CheckOptions:
|
||||
|
||||
17
.github/workflows/reusable-clang-tidy-files.yml
vendored
17
.github/workflows/reusable-clang-tidy-files.yml
vendored
@@ -90,21 +90,8 @@ jobs:
|
||||
path: clang-tidy-output.txt
|
||||
retention-days: 30
|
||||
|
||||
- name: Generate git diff
|
||||
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
|
||||
run: |
|
||||
git diff | tee clang-tidy-git-diff.txt
|
||||
|
||||
- name: Upload clang-tidy diff output
|
||||
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: clang-tidy-git-diff
|
||||
path: clang-tidy-git-diff.txt
|
||||
retention-days: 30
|
||||
|
||||
- name: Create an issue
|
||||
if: ${{ steps.run_clang_tidy.outcome != 'success' && inputs.create_issue_on_failure }}
|
||||
if: steps.run_clang_tidy.outcome != 'success' && inputs.create_issue_on_failure
|
||||
id: create_issue
|
||||
shell: bash
|
||||
env:
|
||||
@@ -169,7 +156,7 @@ jobs:
|
||||
rm -f create_issue.log issue.md clang-tidy-output.txt
|
||||
|
||||
- name: Fail the workflow if clang-tidy failed
|
||||
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
|
||||
if: steps.run_clang_tidy.outcome != 'success'
|
||||
run: |
|
||||
echo "Clang-tidy check failed!"
|
||||
exit 1
|
||||
|
||||
@@ -1416,12 +1416,6 @@
|
||||
# in this section to a comma-separated list of the addresses
|
||||
# of your Clio servers, in order to bypass xrpld's rate limiting.
|
||||
#
|
||||
# TLS/SSL can be enabled for gRPC by specifying ssl_cert and ssl_key.
|
||||
# Both parameters must be provided together. The ssl_cert_chain parameter
|
||||
# is optional and provides intermediate CA certificates for the certificate
|
||||
# chain. The ssl_client_ca parameter is optional and enables mutual TLS
|
||||
# (client certificate verification).
|
||||
#
|
||||
# This port is commented out but can be enabled by removing
|
||||
# the '#' from each corresponding line including the entry under [server]
|
||||
#
|
||||
@@ -1471,74 +1465,11 @@ admin = 127.0.0.1
|
||||
protocol = ws
|
||||
send_queue_limit = 500
|
||||
|
||||
# gRPC TLS/SSL Configuration
|
||||
#
|
||||
# The gRPC port supports optional TLS/SSL encryption. When TLS is not
|
||||
# configured, the gRPC server will accept unencrypted connections.
|
||||
#
|
||||
# ssl_cert = <filename>
|
||||
# ssl_key = <filename>
|
||||
#
|
||||
# To enable TLS for gRPC, both ssl_cert and ssl_key must be specified.
|
||||
# If only one is provided, xrpld will fail to start.
|
||||
#
|
||||
# ssl_cert: Path to the server's SSL certificate file in PEM format.
|
||||
# ssl_key: Path to the server's SSL private key file in PEM format.
|
||||
#
|
||||
# When configured, the gRPC server will only accept TLS-encrypted
|
||||
# connections. Clients must use TLS (secure) channel credentials rather
|
||||
# than plaintext / insecure connections.
|
||||
#
|
||||
# ssl_cert_chain = <filename>
|
||||
#
|
||||
# Optional. Path to intermediate CA certificate(s) in PEM format that
|
||||
# complete the server's certificate chain.
|
||||
#
|
||||
# This file should contain the intermediate CA certificate(s) needed
|
||||
# to build a trust chain from the server certificate (ssl_cert) to a
|
||||
# root CA that clients trust. Multiple certificates should be
|
||||
# concatenated in PEM format.
|
||||
#
|
||||
# This is needed when your server certificate was signed by an
|
||||
# intermediate CA rather than directly by a root CA. Without this,
|
||||
# clients may fail to verify your server certificate.
|
||||
#
|
||||
# If not specified, only the server certificate from ssl_cert will be
|
||||
# presented to clients.
|
||||
#
|
||||
# ssl_client_ca = <filename>
|
||||
#
|
||||
# Optional. Path to a CA certificate file in PEM format for verifying
|
||||
# client certificates (mutual TLS / mTLS).
|
||||
#
|
||||
# When specified, the gRPC server will verify client certificates
|
||||
# against this CA. This enables mutual authentication where both the
|
||||
# server and client verify each other's identity.
|
||||
#
|
||||
# This is typically NOT needed for public-facing gRPC servers. Only
|
||||
# use this if you want to restrict access to clients with valid
|
||||
# certificates signed by the specified CA.
|
||||
#
|
||||
# If not specified, the server will use one-way TLS (server
|
||||
# authentication only) and will accept connections from any client.
|
||||
#
|
||||
[port_grpc]
|
||||
port = 50051
|
||||
ip = 127.0.0.1
|
||||
secure_gateway = 127.0.0.1
|
||||
|
||||
# Optional TLS/SSL configuration for gRPC
|
||||
# To enable TLS, uncomment and configure both ssl_cert and ssl_key:
|
||||
#ssl_cert = /etc/ssl/certs/grpc-server.crt
|
||||
#ssl_key = /etc/ssl/private/grpc-server.key
|
||||
|
||||
# Optional: Include intermediate CA certificates for complete certificate chain
|
||||
#ssl_cert_chain = /etc/ssl/certs/grpc-intermediate-ca.crt
|
||||
|
||||
# Optional: Enable mutual TLS (client certificate verification)
|
||||
# Uncomment to require and verify client certificates:
|
||||
#ssl_client_ca = /etc/ssl/certs/grpc-client-ca.crt
|
||||
|
||||
#[port_ws_public]
|
||||
#port = 6005
|
||||
#ip = 127.0.0.1
|
||||
|
||||
@@ -33,7 +33,7 @@ private:
|
||||
|
||||
public:
|
||||
/** Create an empty section. */
|
||||
explicit Section(std::string name = "");
|
||||
explicit Section(std::string const& name = "");
|
||||
|
||||
/** Returns the name of this section. */
|
||||
std::string const&
|
||||
@@ -275,7 +275,8 @@ public:
|
||||
bool
|
||||
had_trailing_comments() const
|
||||
{
|
||||
return std::ranges::any_of(map_, [](auto s) { return s.second.had_trailing_comments(); });
|
||||
return std::any_of(
|
||||
map_.cbegin(), map_.cend(), [](auto s) { return s.second.had_trailing_comments(); });
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2024 Ripple Labs Inc.
|
||||
|
||||
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 RIPPLE_BASICS_CANPROCESS_H_INCLUDED
|
||||
#define RIPPLE_BASICS_CANPROCESS_H_INCLUDED
|
||||
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
/** RAII class to check if an Item is already being processed on another thread,
|
||||
* as indicated by it's presence in a Collection.
|
||||
*
|
||||
* If the Item is not in the Collection, it will be added under lock in the
|
||||
* ctor, and removed under lock in the dtor. The object will be considered
|
||||
* "usable" and evaluate to `true`.
|
||||
*
|
||||
* If the Item is in the Collection, no changes will be made to the collection,
|
||||
* and the CanProcess object will be considered "unusable".
|
||||
*
|
||||
* It's up to the caller to decide what "usable" and "unusable" mean. (e.g.
|
||||
* Process or skip a block of code, or set a flag.)
|
||||
*
|
||||
* The current use is to avoid lock contention that would be involved in
|
||||
* processing something associated with the Item.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* void IncomingLedgers::acquireAsync(LedgerHash const& hash, ...)
|
||||
* {
|
||||
* if (CanProcess check{acquiresMutex_, pendingAcquires_, hash})
|
||||
* {
|
||||
* acquire(hash, ...);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* bool
|
||||
* NetworkOPsImp::recvValidation(
|
||||
* std::shared_ptr<STValidation> const& val,
|
||||
* std::string const& source)
|
||||
* {
|
||||
* CanProcess check(
|
||||
* validationsMutex_, pendingValidations_, val->getLedgerHash());
|
||||
* BypassAccept bypassAccept =
|
||||
* check ? BypassAccept::no : BypassAccept::yes;
|
||||
* handleNewValidation(app_, val, source, bypassAccept, m_journal);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
class CanProcess
|
||||
{
|
||||
public:
|
||||
template <class Mutex, class Collection, class Item>
|
||||
CanProcess(Mutex& mtx, Collection& collection, Item const& item)
|
||||
: cleanup_(insert(mtx, collection, item))
|
||||
{
|
||||
}
|
||||
|
||||
~CanProcess()
|
||||
{
|
||||
if (cleanup_)
|
||||
cleanup_();
|
||||
}
|
||||
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return static_cast<bool>(cleanup_);
|
||||
}
|
||||
|
||||
private:
|
||||
template <bool useIterator, class Mutex, class Collection, class Item>
|
||||
std::function<void()>
|
||||
doInsert(Mutex& mtx, Collection& collection, Item const& item)
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mtx);
|
||||
// TODO: Use structured binding once LLVM 16 is the minimum supported
|
||||
// version. See also: https://github.com/llvm/llvm-project/issues/48582
|
||||
// https://github.com/llvm/llvm-project/commit/127bf44385424891eb04cff8e52d3f157fc2cb7c
|
||||
auto const insertResult = collection.insert(item);
|
||||
auto const it = insertResult.first;
|
||||
if (!insertResult.second)
|
||||
return {};
|
||||
if constexpr (useIterator)
|
||||
return [&, it]() {
|
||||
std::unique_lock<Mutex> lock(mtx);
|
||||
collection.erase(it);
|
||||
};
|
||||
else
|
||||
return [&]() {
|
||||
std::unique_lock<Mutex> lock(mtx);
|
||||
collection.erase(item);
|
||||
};
|
||||
}
|
||||
|
||||
// Generic insert() function doesn't use iterators because they may get
|
||||
// invalidated
|
||||
template <class Mutex, class Collection, class Item>
|
||||
std::function<void()>
|
||||
insert(Mutex& mtx, Collection& collection, Item const& item)
|
||||
{
|
||||
return doInsert<false>(mtx, collection, item);
|
||||
}
|
||||
|
||||
// Specialize insert() for std::set, which does not invalidate iterators for
|
||||
// insert and erase
|
||||
template <class Mutex, class Item>
|
||||
std::function<void()>
|
||||
insert(Mutex& mtx, std::set<Item>& collection, Item const& item)
|
||||
{
|
||||
return doInsert<true>(mtx, collection, item);
|
||||
}
|
||||
|
||||
// If set, then the item is "usable"
|
||||
std::function<void()> cleanup_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -9,7 +9,9 @@
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl::compression_algorithms {
|
||||
namespace xrpl {
|
||||
|
||||
namespace compression_algorithms {
|
||||
|
||||
/** LZ4 block compression.
|
||||
* @tparam BufferFactory Callable object or lambda.
|
||||
@@ -139,4 +141,6 @@ lz4Decompress(
|
||||
return lz4Decompress(chunk, inSize, decompressed, decompressedSize);
|
||||
}
|
||||
|
||||
} // namespace xrpl::compression_algorithms
|
||||
} // namespace compression_algorithms
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -61,7 +61,7 @@ template <class E>
|
||||
class Unexpected
|
||||
{
|
||||
public:
|
||||
static_assert(!std::is_same_v<E, void>, "E must not be void");
|
||||
static_assert(!std::is_same<E, void>::value, "E must not be void");
|
||||
|
||||
Unexpected() = delete;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
@@ -29,7 +28,7 @@ struct LocalValues
|
||||
T t_;
|
||||
|
||||
Value() = default;
|
||||
explicit Value(T t) : t_(std::move(t))
|
||||
explicit Value(T const& t) : t_(t)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
std::string partition_;
|
||||
|
||||
public:
|
||||
Sink(std::string partition, beast::severities::Severity thresh, Logs& logs);
|
||||
Sink(std::string const& partition, beast::severities::Severity thresh, Logs& logs);
|
||||
|
||||
Sink(Sink const&) = delete;
|
||||
Sink&
|
||||
|
||||
@@ -66,10 +66,12 @@ class SlabAllocator
|
||||
}
|
||||
}
|
||||
|
||||
// Calling this destructor will release the allocated memory but
|
||||
// will not properly destroy any objects that are constructed in
|
||||
// the block itself.
|
||||
~SlabBlock() = default;
|
||||
~SlabBlock()
|
||||
{
|
||||
// Calling this destructor will release the allocated memory but
|
||||
// will not properly destroy any objects that are constructed in
|
||||
// the block itself.
|
||||
}
|
||||
|
||||
SlabBlock(SlabBlock const& other) = delete;
|
||||
SlabBlock&
|
||||
@@ -174,10 +176,12 @@ public:
|
||||
SlabAllocator&
|
||||
operator=(SlabAllocator&& other) = delete;
|
||||
|
||||
// FIXME: We can't destroy the memory blocks we've allocated, because
|
||||
// we can't be sure that they are not being used. Cleaning the
|
||||
// shutdown process up could make this possible.
|
||||
~SlabAllocator() = default;
|
||||
~SlabAllocator()
|
||||
{
|
||||
// FIXME: We can't destroy the memory blocks we've allocated, because
|
||||
// we can't be sure that they are not being used. Cleaning the
|
||||
// shutdown process up could make this possible.
|
||||
}
|
||||
|
||||
/** Returns the size of the memory block this allocator returns. */
|
||||
constexpr std::size_t
|
||||
@@ -343,7 +347,9 @@ public:
|
||||
SlabAllocatorSet&
|
||||
operator=(SlabAllocatorSet&& other) = delete;
|
||||
|
||||
~SlabAllocatorSet() = default;
|
||||
~SlabAllocatorSet()
|
||||
{
|
||||
}
|
||||
|
||||
/** Returns a suitably aligned pointer, if one is available.
|
||||
|
||||
|
||||
@@ -211,14 +211,14 @@ operator<<(Stream& s, Slice const& v)
|
||||
}
|
||||
|
||||
template <class T, std::size_t N>
|
||||
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
|
||||
std::enable_if_t<std::is_same<T, char>::value || std::is_same<T, unsigned char>::value, Slice>
|
||||
makeSlice(std::array<T, N> const& a)
|
||||
{
|
||||
return Slice(a.data(), a.size());
|
||||
}
|
||||
|
||||
template <class T, class Alloc>
|
||||
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
|
||||
std::enable_if_t<std::is_same<T, char>::value || std::is_same<T, unsigned char>::value, Slice>
|
||||
makeSlice(std::vector<T, Alloc> const& v)
|
||||
{
|
||||
return Slice(v.data(), v.size());
|
||||
|
||||
@@ -251,7 +251,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
using Entry = std::conditional_t<IsKeyCache, KeyOnlyEntry, ValueEntry>;
|
||||
typedef typename std::conditional<IsKeyCache, KeyOnlyEntry, ValueEntry>::type Entry;
|
||||
|
||||
using KeyOnlyCacheType = hardened_partitioned_hash_map<key_type, KeyOnlyEntry, Hash, KeyEqual>;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace xrpl {
|
||||
*/
|
||||
|
||||
template <class T>
|
||||
std::enable_if_t<std::is_arithmetic_v<T>, std::string>
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, std::string>::type
|
||||
to_string(T t)
|
||||
{
|
||||
return std::to_string(t);
|
||||
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
class Container,
|
||||
class = std::enable_if_t<
|
||||
detail::is_contiguous_container<Container>::value &&
|
||||
std::is_trivially_copyable_v<typename Container::value_type>>>
|
||||
std::is_trivially_copyable<typename Container::value_type>::value>>
|
||||
explicit base_uint(Container const& c)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
template <class Container>
|
||||
std::enable_if_t<
|
||||
detail::is_contiguous_container<Container>::value &&
|
||||
std::is_trivially_copyable_v<typename Container::value_type>,
|
||||
std::is_trivially_copyable<typename Container::value_type>::value,
|
||||
base_uint&>
|
||||
operator=(Container const& c)
|
||||
{
|
||||
|
||||
@@ -49,7 +49,8 @@ template <class E, class... Args>
|
||||
Throw(Args&&... args)
|
||||
{
|
||||
static_assert(
|
||||
std::is_convertible_v<E*, std::exception*>, "Exception must derive from std::exception.");
|
||||
std::is_convertible<E*, std::exception*>::value,
|
||||
"Exception must derive from std::exception.");
|
||||
|
||||
E e(std::forward<Args>(args)...);
|
||||
LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what());
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace xrpl {
|
||||
#ifndef __INTELLISENSE__
|
||||
static_assert(
|
||||
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||
std::is_integral_v<beast::xor_shift_engine::result_type> &&
|
||||
std::is_unsigned_v<beast::xor_shift_engine::result_type>,
|
||||
std::is_integral<beast::xor_shift_engine::result_type>::value &&
|
||||
std::is_unsigned<beast::xor_shift_engine::result_type>::value,
|
||||
"The XRPL default PRNG engine must return an unsigned integral type.");
|
||||
|
||||
static_assert(
|
||||
@@ -91,7 +91,7 @@ default_prng()
|
||||
*/
|
||||
/** @{ */
|
||||
template <class Engine, class Integral>
|
||||
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value && detail::is_engine<Engine>::value, Integral>
|
||||
rand_int(Engine& engine, Integral min, Integral max)
|
||||
{
|
||||
XRPL_ASSERT(max > min, "xrpl::rand_int : max over min inputs");
|
||||
@@ -103,35 +103,35 @@ rand_int(Engine& engine, Integral min, Integral max)
|
||||
}
|
||||
|
||||
template <class Integral>
|
||||
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value, Integral>
|
||||
rand_int(Integral min, Integral max)
|
||||
{
|
||||
return rand_int(default_prng(), min, max);
|
||||
}
|
||||
|
||||
template <class Engine, class Integral>
|
||||
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value && detail::is_engine<Engine>::value, Integral>
|
||||
rand_int(Engine& engine, Integral max)
|
||||
{
|
||||
return rand_int(engine, Integral(0), max);
|
||||
}
|
||||
|
||||
template <class Integral>
|
||||
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value, Integral>
|
||||
rand_int(Integral max)
|
||||
{
|
||||
return rand_int(default_prng(), max);
|
||||
}
|
||||
|
||||
template <class Integral, class Engine>
|
||||
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value && detail::is_engine<Engine>::value, Integral>
|
||||
rand_int(Engine& engine)
|
||||
{
|
||||
return rand_int(engine, std::numeric_limits<Integral>::max());
|
||||
}
|
||||
|
||||
template <class Integral = int>
|
||||
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value, Integral>
|
||||
rand_int()
|
||||
{
|
||||
return rand_int(default_prng(), std::numeric_limits<Integral>::max());
|
||||
@@ -142,7 +142,7 @@ rand_int()
|
||||
/** @{ */
|
||||
template <class Byte, class Engine>
|
||||
std::enable_if_t<
|
||||
(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>) &&
|
||||
(std::is_same<Byte, unsigned char>::value || std::is_same<Byte, std::uint8_t>::value) &&
|
||||
detail::is_engine<Engine>::value,
|
||||
Byte>
|
||||
rand_byte(Engine& engine)
|
||||
@@ -152,7 +152,9 @@ rand_byte(Engine& engine)
|
||||
}
|
||||
|
||||
template <class Byte = std::uint8_t>
|
||||
std::enable_if_t<(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>), Byte>
|
||||
std::enable_if_t<
|
||||
(std::is_same<Byte, unsigned char>::value || std::is_same<Byte, std::uint8_t>::value),
|
||||
Byte>
|
||||
rand_byte()
|
||||
{
|
||||
return rand_byte<Byte>(default_prng());
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace xrpl {
|
||||
|
||||
template <class Src, class Dest>
|
||||
concept SafeToCast = (std::is_integral_v<Src> && std::is_integral_v<Dest>) &&
|
||||
(std::is_signed_v<Src> || std::is_unsigned_v<Dest>) &&
|
||||
(std::is_signed_v<Src> != std::is_signed_v<Dest> ? sizeof(Dest) > sizeof(Src)
|
||||
: sizeof(Dest) >= sizeof(Src));
|
||||
(std::is_signed<Src>::value || std::is_unsigned<Dest>::value) &&
|
||||
(std::is_signed<Src>::value != std::is_signed<Dest>::value ? sizeof(Dest) > sizeof(Src)
|
||||
: sizeof(Dest) >= sizeof(Src));
|
||||
|
||||
template <class Dest, class Src>
|
||||
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
|
||||
|
||||
@@ -10,9 +10,9 @@ std::string
|
||||
strHex(FwdIt begin, FwdIt end)
|
||||
{
|
||||
static_assert(
|
||||
std::is_convertible_v<
|
||||
std::is_convertible<
|
||||
typename std::iterator_traits<FwdIt>::iterator_category,
|
||||
std::forward_iterator_tag>,
|
||||
std::forward_iterator_tag>::value,
|
||||
"FwdIt must be a forward iterator");
|
||||
std::string result;
|
||||
result.reserve(2 * std::distance(begin, end));
|
||||
|
||||
@@ -44,7 +44,8 @@ public:
|
||||
|
||||
template <
|
||||
class OtherInt,
|
||||
class = std::enable_if_t<std::is_integral_v<OtherInt> && sizeof(OtherInt) <= sizeof(Int)>>
|
||||
class = typename std::enable_if<
|
||||
std::is_integral<OtherInt>::value && sizeof(OtherInt) <= sizeof(Int)>::type>
|
||||
explicit constexpr tagged_integer(OtherInt value) noexcept : m_value(value)
|
||||
{
|
||||
static_assert(sizeof(tagged_integer) == sizeof(Int), "tagged_integer is adding padding");
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace beast {
|
||||
|
||||
/** Expire aged container items past the specified age. */
|
||||
template <class AgedContainer, class Rep, class Period>
|
||||
std::enable_if_t<is_aged_container<AgedContainer>::value, std::size_t>
|
||||
typename std::enable_if<is_aged_container<AgedContainer>::value, std::size_t>::type
|
||||
expire(AgedContainer& c, std::chrono::duration<Rep, Period> const& age)
|
||||
{
|
||||
std::size_t n(0);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace beast::detail {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
// Extracts the key portion of value
|
||||
template <bool maybe_map>
|
||||
@@ -29,4 +30,5 @@ struct aged_associative_container_extract_t<false>
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace beast::detail
|
||||
} // namespace detail
|
||||
} // namespace beast
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -132,7 +131,7 @@ private:
|
||||
friend class aged_container_iterator;
|
||||
|
||||
template <class OtherIterator>
|
||||
aged_container_iterator(OtherIterator iter) : m_iter(std::move(iter))
|
||||
aged_container_iterator(OtherIterator const& iter) : m_iter(iter)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ template <
|
||||
class T,
|
||||
class Clock = std::chrono::steady_clock,
|
||||
class Compare = std::less<Key>,
|
||||
class Allocator = std::allocator<std::conditional_t<IsMap, std::pair<Key const, T>, Key>>>
|
||||
class Allocator =
|
||||
std::allocator<typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type>>
|
||||
class aged_ordered_container
|
||||
{
|
||||
public:
|
||||
@@ -66,7 +67,7 @@ public:
|
||||
using duration = typename clock_type::duration;
|
||||
using key_type = Key;
|
||||
using mapped_type = T;
|
||||
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
|
||||
using value_type = typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
@@ -109,7 +110,8 @@ private:
|
||||
|
||||
template <
|
||||
class... Args,
|
||||
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
|
||||
class =
|
||||
typename std::enable_if<std::is_constructible<value_type, Args...>::value>::type>
|
||||
element(time_point const& when_, Args&&... args)
|
||||
: value(std::forward<Args>(args)...), when(when_)
|
||||
{
|
||||
@@ -133,7 +135,9 @@ private:
|
||||
return Compare::operator()(lhs.first, rhs.first);
|
||||
}
|
||||
|
||||
pair_value_compare() = default;
|
||||
pair_value_compare()
|
||||
{
|
||||
}
|
||||
|
||||
pair_value_compare(pair_value_compare const& other) : Compare(other)
|
||||
{
|
||||
@@ -196,7 +200,7 @@ private:
|
||||
using list_type = typename boost::intrusive::
|
||||
make_list<element, boost::intrusive::constant_time_size<false>>::type;
|
||||
|
||||
using cont_type = std::conditional_t<
|
||||
using cont_type = typename std::conditional<
|
||||
IsMulti,
|
||||
typename boost::intrusive::make_multiset<
|
||||
element,
|
||||
@@ -205,7 +209,7 @@ private:
|
||||
typename boost::intrusive::make_set<
|
||||
element,
|
||||
boost::intrusive::constant_time_size<true>,
|
||||
boost::intrusive::compare<KeyValueCompare>>::type>;
|
||||
boost::intrusive::compare<KeyValueCompare>>::type>::type;
|
||||
|
||||
using ElementAllocator =
|
||||
typename std::allocator_traits<Allocator>::template rebind_alloc<element>;
|
||||
@@ -370,7 +374,7 @@ private:
|
||||
|
||||
public:
|
||||
using key_compare = Compare;
|
||||
using value_compare = std::conditional_t<IsMap, pair_value_compare, Compare>;
|
||||
using value_compare = typename std::conditional<IsMap, pair_value_compare, Compare>::type;
|
||||
using allocator_type = Allocator;
|
||||
using reference = value_type&;
|
||||
using const_reference = value_type const&;
|
||||
@@ -398,8 +402,6 @@ public:
|
||||
|
||||
class chronological_t
|
||||
{
|
||||
chronological_t() = default;
|
||||
|
||||
public:
|
||||
// A set iterator (IsMap==false) is always const
|
||||
// because the elements of a set are immutable.
|
||||
@@ -487,7 +489,7 @@ public:
|
||||
iterator
|
||||
iterator_to(value_type& value)
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return list.iterator_to(*reinterpret_cast<element*>(
|
||||
reinterpret_cast<uint8_t*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -496,16 +498,20 @@ public:
|
||||
const_iterator
|
||||
iterator_to(value_type const& value) const
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return list.iterator_to(*reinterpret_cast<element const*>(
|
||||
reinterpret_cast<uint8_t const*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
}
|
||||
|
||||
private:
|
||||
chronological_t()
|
||||
{
|
||||
}
|
||||
|
||||
chronological_t(chronological_t const&) = delete;
|
||||
chronological_t(chronological_t&&) = delete;
|
||||
|
||||
private:
|
||||
friend class aged_ordered_container;
|
||||
list_type mutable list;
|
||||
} chronological;
|
||||
@@ -611,30 +617,30 @@ public:
|
||||
class K,
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
at(K const& k);
|
||||
|
||||
template <
|
||||
class K,
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type const&
|
||||
at(K const& k) const;
|
||||
|
||||
template <
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
operator[](Key const& key);
|
||||
|
||||
template <
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
operator[](Key&& key);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -718,7 +724,7 @@ public:
|
||||
iterator
|
||||
iterator_to(value_type& value)
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return m_cont.iterator_to(*reinterpret_cast<element*>(
|
||||
reinterpret_cast<uint8_t*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -727,7 +733,7 @@ public:
|
||||
const_iterator
|
||||
iterator_to(value_type const& value) const
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return m_cont.iterator_to(*reinterpret_cast<element const*>(
|
||||
reinterpret_cast<uint8_t const*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -769,35 +775,37 @@ public:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
insert(value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
insert(value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
// set
|
||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||
auto
|
||||
insert(value_type&& value)
|
||||
-> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>;
|
||||
insert(value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset
|
||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||
auto
|
||||
insert(value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>;
|
||||
insert(value_type&& value) ->
|
||||
typename std::enable_if<maybe_multi && !maybe_map, iterator>::type;
|
||||
|
||||
//---
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(const_iterator hint, value_type const& value)
|
||||
-> std::enable_if_t<!maybe_multi, iterator>;
|
||||
insert(const_iterator hint, value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, iterator>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type const& value)
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
@@ -807,11 +815,12 @@ public:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(const_iterator hint, value_type&& value) -> std::enable_if_t<!maybe_multi, iterator>;
|
||||
insert(const_iterator hint, value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi, iterator>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type&& value)
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
@@ -820,9 +829,9 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool maybe_map = IsMap>
|
||||
std::enable_if_t<
|
||||
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
typename std::enable_if<
|
||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
||||
insert(P&& value)
|
||||
{
|
||||
return emplace(std::forward<P>(value));
|
||||
@@ -830,9 +839,9 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool maybe_map = IsMap>
|
||||
std::enable_if_t<
|
||||
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
typename std::enable_if<
|
||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
||||
insert(const_iterator hint, P&& value)
|
||||
{
|
||||
return emplace_hint(hint, std::forward<P>(value));
|
||||
@@ -855,22 +864,23 @@ public:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
emplace(Args&&... args) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
emplace(Args&&... args) -> typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace_hint(const_iterator hint, Args&&... args)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
emplace_hint(const_iterator hint, Args&&... args) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
@@ -1154,12 +1164,12 @@ private:
|
||||
|
||||
template <
|
||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
std::enable_if_t<maybe_propagate>
|
||||
typename std::enable_if<maybe_propagate>::type
|
||||
swap_data(aged_ordered_container& other) noexcept;
|
||||
|
||||
template <
|
||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
std::enable_if_t<!maybe_propagate>
|
||||
typename std::enable_if<!maybe_propagate>::type
|
||||
swap_data(aged_ordered_container& other) noexcept;
|
||||
|
||||
private:
|
||||
@@ -1386,7 +1396,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::opera
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <class K, bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k)
|
||||
{
|
||||
auto const iter(m_cont.find(k, std::cref(m_config.key_compare())));
|
||||
@@ -1408,7 +1418,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](
|
||||
Key const& key)
|
||||
{
|
||||
@@ -1427,7 +1437,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::opera
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](Key&& key)
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -1462,7 +1472,8 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d));
|
||||
@@ -1481,7 +1492,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type const& value) -> std::enable_if_t<maybe_multi, iterator>
|
||||
value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare())));
|
||||
element* const p(new_element(value));
|
||||
@@ -1495,7 +1506,8 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi, bool maybe_map>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type&& value) -> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>
|
||||
value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d));
|
||||
@@ -1514,7 +1526,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi, bool maybe_map>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>
|
||||
value_type&& value) -> typename std::enable_if<maybe_multi && !maybe_map, iterator>::type
|
||||
{
|
||||
auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare())));
|
||||
element* const p(new_element(std::move(value)));
|
||||
@@ -1531,7 +1543,7 @@ template <bool maybe_multi>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
const_iterator hint,
|
||||
value_type const& value) -> std::enable_if_t<!maybe_multi, iterator>
|
||||
value_type const& value) -> typename std::enable_if<!maybe_multi, iterator>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(
|
||||
@@ -1552,7 +1564,7 @@ template <bool maybe_multi>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
const_iterator hint,
|
||||
value_type&& value) -> std::enable_if_t<!maybe_multi, iterator>
|
||||
value_type&& value) -> typename std::enable_if<!maybe_multi, iterator>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(
|
||||
@@ -1572,7 +1584,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
-> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
// construct element here
|
||||
@@ -1594,7 +1606,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
||||
-> std::enable_if_t<maybe_multi, iterator>
|
||||
-> typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
element* const p(new_element(std::forward<Args>(args)...));
|
||||
auto const before(m_cont.upper_bound(extract(p->value), std::cref(m_config.key_compare())));
|
||||
@@ -1609,7 +1621,7 @@ template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace_hint(
|
||||
const_iterator hint,
|
||||
Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
// construct element here
|
||||
@@ -1759,7 +1771,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::touch
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool maybe_propagate>
|
||||
std::enable_if_t<maybe_propagate>
|
||||
typename std::enable_if<maybe_propagate>::type
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_data(
|
||||
aged_ordered_container& other) noexcept
|
||||
{
|
||||
@@ -1770,7 +1782,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool maybe_propagate>
|
||||
std::enable_if_t<!maybe_propagate>
|
||||
typename std::enable_if<!maybe_propagate>::type
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_data(
|
||||
aged_ordered_container& other) noexcept
|
||||
{
|
||||
|
||||
@@ -62,7 +62,8 @@ template <
|
||||
class Clock = std::chrono::steady_clock,
|
||||
class Hash = std::hash<Key>,
|
||||
class KeyEqual = std::equal_to<Key>,
|
||||
class Allocator = std::allocator<std::conditional_t<IsMap, std::pair<Key const, T>, Key>>>
|
||||
class Allocator =
|
||||
std::allocator<typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type>>
|
||||
class aged_unordered_container
|
||||
{
|
||||
public:
|
||||
@@ -71,7 +72,7 @@ public:
|
||||
using duration = typename clock_type::duration;
|
||||
using key_type = Key;
|
||||
using mapped_type = T;
|
||||
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
|
||||
using value_type = typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
@@ -114,7 +115,8 @@ private:
|
||||
|
||||
template <
|
||||
class... Args,
|
||||
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
|
||||
class =
|
||||
typename std::enable_if<std::is_constructible<value_type, Args...>::value>::type>
|
||||
element(time_point const& when_, Args&&... args)
|
||||
: value(std::forward<Args>(args)...), when(when_)
|
||||
{
|
||||
@@ -131,7 +133,9 @@ private:
|
||||
using argument_type = element;
|
||||
using result_type = size_t;
|
||||
|
||||
ValueHash() = default;
|
||||
ValueHash()
|
||||
{
|
||||
}
|
||||
|
||||
ValueHash(Hash const& h) : Hash(h)
|
||||
{
|
||||
@@ -165,7 +169,9 @@ private:
|
||||
using second_argument_type = element;
|
||||
using result_type = bool;
|
||||
|
||||
KeyValueEqual() = default;
|
||||
KeyValueEqual()
|
||||
{
|
||||
}
|
||||
|
||||
KeyValueEqual(KeyEqual const& keyEqual) : KeyEqual(keyEqual)
|
||||
{
|
||||
@@ -205,7 +211,7 @@ private:
|
||||
using list_type = typename boost::intrusive::
|
||||
make_list<element, boost::intrusive::constant_time_size<false>>::type;
|
||||
|
||||
using cont_type = std::conditional_t<
|
||||
using cont_type = typename std::conditional<
|
||||
IsMulti,
|
||||
typename boost::intrusive::make_unordered_multiset<
|
||||
element,
|
||||
@@ -218,7 +224,7 @@ private:
|
||||
boost::intrusive::constant_time_size<true>,
|
||||
boost::intrusive::hash<ValueHash>,
|
||||
boost::intrusive::equal<KeyValueEqual>,
|
||||
boost::intrusive::cache_begin<true>>::type>;
|
||||
boost::intrusive::cache_begin<true>>::type>::type;
|
||||
|
||||
using bucket_type = typename cont_type::bucket_type;
|
||||
using bucket_traits = typename cont_type::bucket_traits;
|
||||
@@ -656,7 +662,7 @@ public:
|
||||
iterator
|
||||
iterator_to(value_type& value)
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return list.iterator_to(*reinterpret_cast<element*>(
|
||||
reinterpret_cast<uint8_t*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -665,17 +671,20 @@ public:
|
||||
const_iterator
|
||||
iterator_to(value_type const& value) const
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return list.iterator_to(*reinterpret_cast<element const*>(
|
||||
reinterpret_cast<uint8_t const*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
}
|
||||
|
||||
private:
|
||||
chronological_t()
|
||||
{
|
||||
}
|
||||
|
||||
chronological_t(chronological_t const&) = delete;
|
||||
chronological_t(chronological_t&&) = delete;
|
||||
chronological_t() = default;
|
||||
|
||||
private:
|
||||
friend class aged_unordered_container;
|
||||
list_type mutable list;
|
||||
} chronological;
|
||||
@@ -853,30 +862,30 @@ public:
|
||||
class K,
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
at(K const& k);
|
||||
|
||||
template <
|
||||
class K,
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type const&
|
||||
at(K const& k) const;
|
||||
|
||||
template <
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
operator[](Key const& key);
|
||||
|
||||
template <
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
operator[](Key&& key);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -924,7 +933,7 @@ public:
|
||||
iterator
|
||||
iterator_to(value_type& value)
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return m_cont.iterator_to(*reinterpret_cast<element*>(
|
||||
reinterpret_cast<uint8_t*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -933,7 +942,7 @@ public:
|
||||
const_iterator
|
||||
iterator_to(value_type const& value) const
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return m_cont.iterator_to(*reinterpret_cast<element const*>(
|
||||
reinterpret_cast<uint8_t const*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -975,27 +984,29 @@ public:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
insert(value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
insert(value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||
auto
|
||||
insert(value_type&& value)
|
||||
-> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>;
|
||||
insert(value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||
auto
|
||||
insert(value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>;
|
||||
insert(value_type&& value) ->
|
||||
typename std::enable_if<maybe_multi && !maybe_map, iterator>::type;
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<!maybe_multi, iterator>
|
||||
typename std::enable_if<!maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type const& value)
|
||||
{
|
||||
// Hint is ignored but we provide the interface so
|
||||
@@ -1005,7 +1016,7 @@ public:
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type const& value)
|
||||
{
|
||||
// VFALCO TODO The hint could be used to let
|
||||
@@ -1015,7 +1026,7 @@ public:
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<!maybe_multi, iterator>
|
||||
typename std::enable_if<!maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type&& value)
|
||||
{
|
||||
// Hint is ignored but we provide the interface so
|
||||
@@ -1025,7 +1036,7 @@ public:
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type&& value)
|
||||
{
|
||||
// VFALCO TODO The hint could be used to let
|
||||
@@ -1035,9 +1046,9 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool maybe_map = IsMap>
|
||||
std::enable_if_t<
|
||||
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
typename std::enable_if<
|
||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
||||
insert(P&& value)
|
||||
{
|
||||
return emplace(std::forward<P>(value));
|
||||
@@ -1045,9 +1056,9 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool maybe_map = IsMap>
|
||||
std::enable_if_t<
|
||||
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
typename std::enable_if<
|
||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
||||
insert(const_iterator hint, P&& value)
|
||||
{
|
||||
return emplace_hint(hint, std::forward<P>(value));
|
||||
@@ -1069,22 +1080,23 @@ public:
|
||||
// set, map
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
emplace(Args&&... args) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
emplace(Args&&... args) -> typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
// set, map
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
emplace_hint(const_iterator /*hint*/, Args&&... args) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
||||
{
|
||||
// VFALCO TODO The hint could be used for multi, to let
|
||||
@@ -1316,7 +1328,7 @@ public:
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<!maybe_multi, bool>
|
||||
typename std::enable_if<!maybe_multi, bool>::type
|
||||
operator==(aged_unordered_container<
|
||||
false,
|
||||
OtherIsMap,
|
||||
@@ -1335,7 +1347,7 @@ public:
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, bool>
|
||||
typename std::enable_if<maybe_multi, bool>::type
|
||||
operator==(aged_unordered_container<
|
||||
true,
|
||||
OtherIsMap,
|
||||
@@ -1389,13 +1401,14 @@ private:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert_unchecked(value_type const& value)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
insert_unchecked(value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert_unchecked(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
insert_unchecked(value_type const& value) ->
|
||||
typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
template <class InputIt>
|
||||
void
|
||||
@@ -1436,7 +1449,7 @@ private:
|
||||
|
||||
template <
|
||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
std::enable_if_t<maybe_propagate>
|
||||
typename std::enable_if<maybe_propagate>::type
|
||||
swap_data(aged_unordered_container& other) noexcept
|
||||
{
|
||||
std::swap(m_config.key_compare(), other.m_config.key_compare());
|
||||
@@ -1446,7 +1459,7 @@ private:
|
||||
|
||||
template <
|
||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
std::enable_if_t<!maybe_propagate>
|
||||
typename std::enable_if<!maybe_propagate>::type
|
||||
swap_data(aged_unordered_container& other) noexcept
|
||||
{
|
||||
std::swap(m_config.key_compare(), other.m_config.key_compare());
|
||||
@@ -2101,7 +2114,7 @@ template <
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <class K, bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(K const& k)
|
||||
{
|
||||
auto const iter(
|
||||
@@ -2142,7 +2155,7 @@ template <
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
||||
Key const& key)
|
||||
{
|
||||
@@ -2171,7 +2184,7 @@ template <
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
||||
Key&& key)
|
||||
{
|
||||
@@ -2226,7 +2239,8 @@ template <
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -2258,7 +2272,7 @@ template <
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type const& value) -> std::enable_if_t<maybe_multi, iterator>
|
||||
value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
element* const p(new_element(value));
|
||||
@@ -2280,7 +2294,8 @@ template <
|
||||
template <bool maybe_multi, bool maybe_map>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type&& value) -> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>
|
||||
value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -2312,7 +2327,7 @@ template <
|
||||
template <bool maybe_multi, bool maybe_map>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>
|
||||
value_type&& value) -> typename std::enable_if<maybe_multi && !maybe_map, iterator>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
element* const p(new_element(std::move(value)));
|
||||
@@ -2335,7 +2350,7 @@ template <
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
||||
Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
@@ -2400,7 +2415,7 @@ template <
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
||||
Args&&... args) -> std::enable_if_t<maybe_multi, iterator>
|
||||
Args&&... args) -> typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
element* const p(new_element(std::forward<Args>(args)...));
|
||||
@@ -2423,7 +2438,7 @@ template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace_hint(
|
||||
const_iterator /*hint*/,
|
||||
Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
@@ -2575,7 +2590,7 @@ template <
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi>
|
||||
std::enable_if_t<!maybe_multi, bool>
|
||||
typename std::enable_if<!maybe_multi, bool>::type
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
||||
aged_unordered_container<
|
||||
false,
|
||||
@@ -2615,7 +2630,7 @@ template <
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi>
|
||||
std::enable_if_t<maybe_multi, bool>
|
||||
typename std::enable_if<maybe_multi, bool>::type
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
||||
aged_unordered_container<
|
||||
true,
|
||||
@@ -2662,8 +2677,8 @@ template <
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
|
||||
insert_unchecked(value_type const& value)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
insert_unchecked(value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(m_cont.insert_check(
|
||||
@@ -2694,7 +2709,8 @@ template <
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
|
||||
insert_unchecked(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>
|
||||
insert_unchecked(value_type const& value) ->
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
element* const p(new_element(value));
|
||||
chronological.list.push_back(*p);
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::detail {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
template <class T>
|
||||
struct is_empty_base_optimization_derived
|
||||
: std::integral_constant<bool, std::is_empty_v<T> && !boost::is_final<T>::value>
|
||||
: std::integral_constant<bool, std::is_empty<T>::value && !boost::is_final<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
@@ -85,4 +86,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace beast::detail
|
||||
} // namespace detail
|
||||
} // namespace beast
|
||||
|
||||
@@ -16,7 +16,7 @@ struct CopyConst
|
||||
{
|
||||
explicit CopyConst() = default;
|
||||
|
||||
using type = std::remove_const_t<U>;
|
||||
using type = typename std::remove_const<U>::type;
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
|
||||
@@ -13,16 +13,18 @@ class LockFreeStackIterator
|
||||
{
|
||||
protected:
|
||||
using Node = typename Container::Node;
|
||||
using NodePtr = std::conditional_t<IsConst, Node const*, Node*>;
|
||||
using NodePtr = typename std::conditional<IsConst, Node const*, Node*>::type;
|
||||
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using value_type = typename Container::value_type;
|
||||
using difference_type = typename Container::difference_type;
|
||||
using pointer =
|
||||
std::conditional_t<IsConst, typename Container::const_pointer, typename Container::pointer>;
|
||||
using reference = std::
|
||||
conditional_t<IsConst, typename Container::const_reference, typename Container::reference>;
|
||||
using pointer = typename std::
|
||||
conditional<IsConst, typename Container::const_pointer, typename Container::pointer>::type;
|
||||
using reference = typename std::conditional<
|
||||
IsConst,
|
||||
typename Container::const_reference,
|
||||
typename Container::reference>::type;
|
||||
|
||||
LockFreeStackIterator() : m_node()
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ template <class T>
|
||||
struct is_uniquely_represented
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral_v<T> || std::is_enum_v<T> || std::is_pointer_v<T>>
|
||||
std::is_integral<T>::value || std::is_enum<T>::value || std::is_pointer<T>::value>
|
||||
{
|
||||
explicit is_uniquely_represented() = default;
|
||||
};
|
||||
@@ -210,7 +210,7 @@ hash_append(Hasher& h, T const& t) noexcept
|
||||
template <class Hasher, class T>
|
||||
inline std::enable_if_t<
|
||||
!is_contiguously_hashable<T, Hasher>::value &&
|
||||
(std::is_integral_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>)>
|
||||
(std::is_integral<T>::value || std::is_pointer<T>::value || std::is_enum<T>::value)>
|
||||
hash_append(Hasher& h, T t) noexcept
|
||||
{
|
||||
detail::reverse_bytes(t);
|
||||
@@ -218,7 +218,7 @@ hash_append(Hasher& h, T t) noexcept
|
||||
}
|
||||
|
||||
template <class Hasher, class T>
|
||||
inline std::enable_if_t<std::is_floating_point_v<T>>
|
||||
inline std::enable_if_t<std::is_floating_point<T>::value>
|
||||
hash_append(Hasher& h, T t) noexcept
|
||||
{
|
||||
if (t == 0)
|
||||
|
||||
@@ -121,13 +121,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned<Seed>::value>* = nullptr>
|
||||
explicit xxhasher(Seed seed) : seed_(seed)
|
||||
{
|
||||
resetBuffers();
|
||||
}
|
||||
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned<Seed>::value>* = nullptr>
|
||||
xxhasher(Seed seed, Seed) : seed_(seed)
|
||||
{
|
||||
resetBuffers();
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** Interface for a manager that allows collection of metrics.
|
||||
|
||||
@@ -116,4 +117,5 @@ public:
|
||||
/** @} */
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A metric for measuring an integral value.
|
||||
|
||||
@@ -22,7 +23,9 @@ public:
|
||||
/** Create a null metric.
|
||||
A null metric reports no information.
|
||||
*/
|
||||
Counter() = default;
|
||||
Counter()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create the metric reference the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -88,4 +91,5 @@ private:
|
||||
std::shared_ptr<CounterImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class Counter;
|
||||
|
||||
@@ -17,4 +18,5 @@ public:
|
||||
increment(value_type amount) = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A metric for reporting event timing.
|
||||
|
||||
@@ -24,7 +25,9 @@ public:
|
||||
/** Create a null metric.
|
||||
A null metric reports no information.
|
||||
*/
|
||||
Event() = default;
|
||||
Event()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create the metric reference the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -55,4 +58,5 @@ private:
|
||||
std::shared_ptr<EventImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class Event;
|
||||
|
||||
@@ -17,4 +18,5 @@ public:
|
||||
notify(value_type const& value) = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A metric for measuring an integral value.
|
||||
|
||||
@@ -24,7 +25,9 @@ public:
|
||||
/** Create a null metric.
|
||||
A null metric reports no information.
|
||||
*/
|
||||
Gauge() = default;
|
||||
Gauge()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create the metric reference the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -118,4 +121,5 @@ private:
|
||||
std::shared_ptr<GaugeImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class Gauge;
|
||||
|
||||
@@ -20,4 +21,5 @@ public:
|
||||
increment(difference_type amount) = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A collector front-end that manages a group of metrics. */
|
||||
class Group : public Collector
|
||||
@@ -18,4 +19,5 @@ public:
|
||||
name() const = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A container for managing a set of metric groups. */
|
||||
class Groups
|
||||
@@ -31,4 +32,5 @@ public:
|
||||
std::unique_ptr<Groups>
|
||||
make_Groups(Collector::ptr const& collector);
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A reference to a handler for performing polled collection. */
|
||||
class Hook final
|
||||
@@ -13,7 +14,9 @@ public:
|
||||
/** Create a null hook.
|
||||
A null hook has no associated handler.
|
||||
*/
|
||||
Hook() = default;
|
||||
Hook()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create a hook referencing the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -34,4 +37,5 @@ private:
|
||||
std::shared_ptr<HookImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class HookImpl : public std::enable_shared_from_this<HookImpl>
|
||||
{
|
||||
@@ -13,4 +14,5 @@ public:
|
||||
virtual ~HookImpl() = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A metric for measuring an integral value.
|
||||
|
||||
@@ -21,7 +22,9 @@ public:
|
||||
/** Create a null metric.
|
||||
A null metric reports no information.
|
||||
*/
|
||||
Meter() = default;
|
||||
Meter()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create the metric reference the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -73,4 +76,5 @@ private:
|
||||
std::shared_ptr<MeterImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class Meter;
|
||||
|
||||
@@ -17,4 +18,5 @@ public:
|
||||
increment(value_type amount) = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
#include <xrpl/beast/insight/Collector.h>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A Collector which does not collect metrics. */
|
||||
class NullCollector : public Collector
|
||||
@@ -14,4 +15,5 @@ public:
|
||||
New();
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include <xrpl/beast/net/IPEndpoint.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A Collector that reports metrics to a StatsD server.
|
||||
Reference:
|
||||
@@ -24,4 +25,5 @@ public:
|
||||
New(IP::Endpoint const& address, std::string const& prefix, Journal journal);
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace beast::IP {
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
|
||||
/** Convert to Endpoint.
|
||||
The port is set to zero.
|
||||
@@ -26,7 +27,8 @@ to_asio_address(Endpoint const& endpoint);
|
||||
boost::asio::ip::tcp::endpoint
|
||||
to_asio_endpoint(Endpoint const& endpoint);
|
||||
|
||||
} // namespace beast::IP
|
||||
} // namespace IP
|
||||
} // namespace beast
|
||||
|
||||
namespace beast {
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <boost/asio/ip/address_v4.hpp>
|
||||
|
||||
namespace beast::IP {
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
|
||||
using AddressV4 = boost::asio::ip::address_v4;
|
||||
|
||||
@@ -22,4 +23,5 @@ is_public(AddressV4 const& addr);
|
||||
char
|
||||
get_class(AddressV4 const& address);
|
||||
|
||||
} // namespace beast::IP
|
||||
} // namespace IP
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
|
||||
namespace beast::IP {
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
|
||||
using AddressV6 = boost::asio::ip::address_v6;
|
||||
|
||||
@@ -16,4 +17,5 @@ is_private(AddressV6 const& addr);
|
||||
bool
|
||||
is_public(AddressV6 const& addr);
|
||||
|
||||
} // namespace beast::IP
|
||||
} // namespace IP
|
||||
} // namespace beast
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace beast::IP {
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
|
||||
using Port = std::uint16_t;
|
||||
|
||||
@@ -20,7 +21,7 @@ public:
|
||||
Endpoint();
|
||||
|
||||
/** Create an endpoint from the address and optional port. */
|
||||
explicit Endpoint(Address addr, Port port = 0);
|
||||
explicit Endpoint(Address const& addr, Port port = 0);
|
||||
|
||||
/** Create an Endpoint from a string.
|
||||
If the port is omitted, the endpoint will have a zero port.
|
||||
@@ -183,7 +184,8 @@ operator<<(OutputStream& os, Endpoint const& endpoint)
|
||||
std::istream&
|
||||
operator>>(std::istream& is, Endpoint& endpoint);
|
||||
|
||||
} // namespace beast::IP
|
||||
} // namespace IP
|
||||
} // namespace beast
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace beast::rfc2616 {
|
||||
namespace beast {
|
||||
namespace rfc2616 {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -369,4 +370,5 @@ is_keep_alive(boost::beast::http::message<isRequest, Body, Fields> const& m)
|
||||
"close");
|
||||
}
|
||||
|
||||
} // namespace beast::rfc2616
|
||||
} // namespace rfc2616
|
||||
} // namespace beast
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace beast::test {
|
||||
namespace beast {
|
||||
namespace test {
|
||||
|
||||
/** Mix-in to support tests using asio coroutines.
|
||||
|
||||
@@ -124,4 +125,5 @@ enable_yield_to::spawn(F0&& f, FN&&... fn)
|
||||
spawn(fn...);
|
||||
}
|
||||
|
||||
} // namespace beast::test
|
||||
} // namespace test
|
||||
} // namespace beast
|
||||
|
||||
@@ -15,7 +15,7 @@ template <typename T>
|
||||
std::string
|
||||
type_name()
|
||||
{
|
||||
using TR = std::remove_reference_t<T>;
|
||||
using TR = typename std::remove_reference<T>::type;
|
||||
|
||||
std::string name = typeid(TR).name();
|
||||
|
||||
@@ -27,15 +27,15 @@ type_name()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (std::is_const_v<TR>)
|
||||
if (std::is_const<TR>::value)
|
||||
name += " const";
|
||||
if (std::is_volatile_v<TR>)
|
||||
if (std::is_volatile<TR>::value)
|
||||
name += " volatile";
|
||||
if (std::is_lvalue_reference_v<T>)
|
||||
if (std::is_lvalue_reference<T>::value)
|
||||
{
|
||||
name += "&";
|
||||
}
|
||||
else if (std::is_rvalue_reference_v<T>)
|
||||
else if (std::is_rvalue_reference<T>::value)
|
||||
{
|
||||
name += "&&";
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** Utility for producing nicely composed output of amounts with units. */
|
||||
class amount
|
||||
@@ -41,4 +42,5 @@ operator<<(std::ostream& s, amount const& t)
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace beast::unit_test::detail {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
namespace detail {
|
||||
|
||||
/** Adapter to constrain a container interface.
|
||||
The interface allows for limited read only operations. Derived classes
|
||||
@@ -80,4 +82,6 @@ public:
|
||||
/** @} */
|
||||
};
|
||||
|
||||
} // namespace beast::unit_test::detail
|
||||
} // namespace detail
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/suite_list.h>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -41,4 +42,5 @@ global_suites()
|
||||
return detail::global_suites();
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
// Predicate for implementing matches
|
||||
class selector
|
||||
@@ -162,4 +163,5 @@ match_library(std::string const& name)
|
||||
return selector(selector::library, name);
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#include <xrpl/beast/unit_test/results.h>
|
||||
#include <xrpl/beast/unit_test/runner.h>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** A test runner that stores the results. */
|
||||
class recorder : public runner
|
||||
@@ -28,48 +29,49 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
virtual void
|
||||
on_suite_begin(suite_info const& info) override
|
||||
{
|
||||
m_suite = suite_results(info.full_name());
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_suite_end() override
|
||||
{
|
||||
m_results.insert(std::move(m_suite));
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_case_begin(std::string const& name) override
|
||||
{
|
||||
m_case = case_results(name);
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_case_end() override
|
||||
{
|
||||
if (!m_case.tests.empty())
|
||||
m_suite.insert(std::move(m_case));
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_pass() override
|
||||
{
|
||||
m_case.tests.pass();
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_fail(std::string const& reason) override
|
||||
{
|
||||
m_case.tests.fail(reason);
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_log(std::string const& s) override
|
||||
{
|
||||
m_case.log.insert(s);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -85,7 +86,7 @@ public:
|
||||
reporter&
|
||||
operator=(reporter const&) = delete;
|
||||
|
||||
~reporter() override;
|
||||
~reporter();
|
||||
|
||||
explicit reporter(std::ostream& os = std::cout);
|
||||
|
||||
@@ -93,25 +94,25 @@ private:
|
||||
static std::string
|
||||
fmtdur(typename clock_type::duration const& d);
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_suite_begin(suite_info const& info) override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_suite_end() override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_case_begin(std::string const& name) override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_case_end() override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_pass() override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_fail(std::string const& reason) override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_log(std::string const& s) override;
|
||||
};
|
||||
|
||||
@@ -250,4 +251,5 @@ reporter<Unused>::on_log(std::string const& s)
|
||||
|
||||
using reporter = detail::reporter<>;
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
#include <xrpl/beast/unit_test/detail/const_container.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** Holds a set of test condition outcomes in a testcase. */
|
||||
class case_results
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
test(bool pass_, std::string reason_) : pass(pass_), reason(std::move(reason_))
|
||||
test(bool pass_, std::string const& reason_) : pass(pass_), reason(reason_)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -38,7 +38,9 @@ private:
|
||||
std::size_t failed_{0};
|
||||
|
||||
public:
|
||||
tests_t() = default;
|
||||
tests_t()
|
||||
{
|
||||
}
|
||||
|
||||
/** Returns the total number of test conditions. */
|
||||
std::size_t
|
||||
@@ -84,7 +86,7 @@ private:
|
||||
std::string name_;
|
||||
|
||||
public:
|
||||
explicit case_results(std::string name = "") : name_(std::move(name))
|
||||
explicit case_results(std::string const& name = "") : name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -113,7 +115,7 @@ private:
|
||||
std::size_t failed_ = 0;
|
||||
|
||||
public:
|
||||
explicit suite_results(std::string name = "") : name_(std::move(name))
|
||||
explicit suite_results(std::string const& name = "") : name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -170,7 +172,9 @@ private:
|
||||
std::size_t failed_{0};
|
||||
|
||||
public:
|
||||
results() = default;
|
||||
results()
|
||||
{
|
||||
}
|
||||
|
||||
/** Returns the total number of test cases. */
|
||||
std::size_t
|
||||
@@ -215,4 +219,5 @@ public:
|
||||
/** @} */
|
||||
};
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** Unit test runner interface.
|
||||
|
||||
@@ -276,4 +277,5 @@ runner::log(std::string const& s)
|
||||
on_log(s);
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -74,7 +75,7 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
~log_buf() override
|
||||
~log_buf()
|
||||
{
|
||||
sync();
|
||||
}
|
||||
@@ -572,7 +573,8 @@ suite::run(runner& r)
|
||||
((cond) ? (pass(), true) : (fail((reason), __FILE__, __LINE__), false))
|
||||
#endif
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
class runner;
|
||||
|
||||
@@ -109,4 +110,5 @@ make_suite_info(
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#include <typeindex>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/// A container of test suites.
|
||||
class suite_list : public detail::const_container<std::set<suite_info>>
|
||||
@@ -61,4 +62,5 @@ suite_list::insert(
|
||||
cont().emplace(make_suite_info<Suite>(name, module, library, manual, priority));
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** Replacement for std::thread that handles exceptions in unit tests. */
|
||||
class Thread
|
||||
@@ -107,4 +108,5 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -55,16 +55,15 @@ public:
|
||||
class Sink
|
||||
{
|
||||
protected:
|
||||
Sink() = delete;
|
||||
explicit Sink(Sink const& sink) = default;
|
||||
Sink(Severity thresh, bool console);
|
||||
Sink&
|
||||
operator=(Sink const& lhs) = delete;
|
||||
|
||||
public:
|
||||
virtual ~Sink() = 0;
|
||||
|
||||
Sink() = delete;
|
||||
Sink&
|
||||
operator=(Sink const& lhs) = delete;
|
||||
|
||||
/** Returns `true` if text at the passed severity produces output. */
|
||||
virtual bool
|
||||
active(Severity level) const;
|
||||
@@ -372,6 +371,10 @@ class logstream_buf : public std::basic_stringbuf<CharT, Traits>
|
||||
{
|
||||
beast::Journal::Stream strm_;
|
||||
|
||||
template <class T>
|
||||
void
|
||||
write(T const*) = delete;
|
||||
|
||||
void
|
||||
write(char const* s)
|
||||
{
|
||||
@@ -391,7 +394,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~logstream_buf() override
|
||||
~logstream_buf()
|
||||
{
|
||||
sync();
|
||||
}
|
||||
@@ -403,10 +406,6 @@ public:
|
||||
this->str("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
write(T const*) = delete;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -414,11 +413,11 @@ public:
|
||||
template <class CharT, class Traits = std::char_traits<CharT>>
|
||||
class basic_logstream : public std::basic_ostream<CharT, Traits>
|
||||
{
|
||||
using char_type = CharT;
|
||||
using traits_type = Traits;
|
||||
using int_type = typename traits_type::int_type;
|
||||
using pos_type = typename traits_type::pos_type;
|
||||
using off_type = typename traits_type::off_type;
|
||||
typedef CharT char_type;
|
||||
typedef Traits traits_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
detail::logstream_buf<CharT, Traits> buf_;
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ private:
|
||||
std::ostringstream mutable m_ostream;
|
||||
|
||||
public:
|
||||
Proxy(Map const& map, std::string key);
|
||||
Proxy(Map const& map, std::string const& key);
|
||||
Proxy(Proxy const& other);
|
||||
~Proxy();
|
||||
|
||||
@@ -315,7 +315,7 @@ private:
|
||||
List<Item> children_;
|
||||
|
||||
public:
|
||||
explicit Source(std::string name);
|
||||
explicit Source(std::string const& name);
|
||||
virtual ~Source();
|
||||
|
||||
Source(Source const&) = delete;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace beast {
|
||||
|
||||
/** Wraps a Journal::Sink to prefix its output with a string. */
|
||||
@@ -19,8 +17,8 @@ private:
|
||||
std::string prefix_;
|
||||
|
||||
public:
|
||||
explicit WrappedSink(beast::Journal::Sink& sink, std::string prefix = "")
|
||||
: Sink(sink), sink_(sink), prefix_(std::move(prefix))
|
||||
explicit WrappedSink(beast::Journal::Sink& sink, std::string const& prefix = "")
|
||||
: Sink(sink), sink_(sink), prefix_(prefix)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ signum(T const& t)
|
||||
return t.signum();
|
||||
}
|
||||
|
||||
namespace detail::zero_helper {
|
||||
namespace detail {
|
||||
namespace zero_helper {
|
||||
|
||||
// For argument dependent lookup to function properly, calls to signum must
|
||||
// be made from a namespace that does not include overloads of the function..
|
||||
@@ -49,7 +50,8 @@ call_signum(T const& t)
|
||||
return signum(t);
|
||||
}
|
||||
|
||||
} // namespace detail::zero_helper
|
||||
} // namespace zero_helper
|
||||
} // namespace detail
|
||||
|
||||
// Handle operators where T is on the left side using signum.
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@ template <bool IsConst, class T>
|
||||
struct maybe_const
|
||||
{
|
||||
explicit maybe_const() = default;
|
||||
using type = std::
|
||||
conditional_t<IsConst, typename std::remove_const<T>::type const, std::remove_const_t<T>>;
|
||||
using type = typename std::conditional<
|
||||
IsConst,
|
||||
typename std::remove_const<T>::type const,
|
||||
typename std::remove_const<T>::type>::type;
|
||||
};
|
||||
|
||||
/** Alias for omitting `typename`. */
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
|
||||
namespace xrpl::cryptoconditions {
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
enum class Type : std::uint8_t {
|
||||
preimageSha256 = 0,
|
||||
@@ -87,4 +88,6 @@ operator!=(Condition const& lhs, Condition const& rhs)
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
} // namespace xrpl::cryptoconditions
|
||||
} // namespace cryptoconditions
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include <xrpl/basics/Slice.h>
|
||||
#include <xrpl/conditions/Condition.h>
|
||||
|
||||
namespace xrpl::cryptoconditions {
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
struct Fulfillment
|
||||
{
|
||||
@@ -118,4 +119,5 @@ validate(Fulfillment const& f, Condition const& c, Slice m);
|
||||
bool
|
||||
validate(Fulfillment const& f, Condition const& c);
|
||||
|
||||
} // namespace xrpl::cryptoconditions
|
||||
} // namespace cryptoconditions
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace xrpl::cryptoconditions {
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
class PreimageSha256 final : public Fulfillment
|
||||
{
|
||||
@@ -126,4 +127,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::cryptoconditions
|
||||
} // namespace cryptoconditions
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
#include <system_error>
|
||||
|
||||
namespace xrpl::cryptoconditions {
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
enum class error {
|
||||
generic = 1,
|
||||
@@ -27,7 +28,8 @@ enum class error {
|
||||
std::error_code
|
||||
make_error_code(error ev);
|
||||
|
||||
} // namespace xrpl::cryptoconditions
|
||||
} // namespace cryptoconditions
|
||||
} // namespace xrpl
|
||||
|
||||
namespace std {
|
||||
|
||||
|
||||
@@ -8,12 +8,15 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
// A collection of functions to decode binary blobs
|
||||
// encoded with X.690 Distinguished Encoding Rules.
|
||||
//
|
||||
// This is a very trivial decoder and only implements
|
||||
// the bare minimum needed to support PreimageSha256.
|
||||
namespace xrpl::cryptoconditions::der {
|
||||
namespace der {
|
||||
|
||||
// The preamble encapsulates the DER identifier and
|
||||
// length octets:
|
||||
@@ -201,4 +204,6 @@ parseInteger(Slice& s, std::size_t count, std::error_code& ec)
|
||||
return v;
|
||||
}
|
||||
|
||||
} // namespace xrpl::cryptoconditions::der
|
||||
} // namespace der
|
||||
} // namespace cryptoconditions
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
std::remove_reference_t<Closure> closure_;
|
||||
|
||||
static_assert(
|
||||
std::is_same_v<decltype(closure_(std::declval<Args_t>()...)), Ret_t>,
|
||||
std::is_same<decltype(closure_(std::declval<Args_t>()...)), Ret_t>::value,
|
||||
"Closure arguments don't match ClosureCounter Ret_t or Args_t");
|
||||
|
||||
public:
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
++counter_;
|
||||
}
|
||||
|
||||
Substitute(Substitute&& rhs) noexcept(std::is_nothrow_move_constructible_v<Closure>)
|
||||
Substitute(Substitute&& rhs) noexcept(std::is_nothrow_move_constructible<Closure>::value)
|
||||
: counter_(rhs.counter_), closure_(std::move(rhs.closure_))
|
||||
{
|
||||
++counter_;
|
||||
|
||||
@@ -109,7 +109,9 @@ private:
|
||||
class Entry : public CountedObject<Entry>
|
||||
{
|
||||
public:
|
||||
Entry() = default;
|
||||
Entry()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
addPeer(PeerShortID peer)
|
||||
@@ -137,13 +139,6 @@ private:
|
||||
return std::move(peers_);
|
||||
}
|
||||
|
||||
/** Return set of peers waiting for reply. Leaves list unchanged. */
|
||||
std::set<PeerShortID> const&
|
||||
peekPeerSet()
|
||||
{
|
||||
return peers_;
|
||||
}
|
||||
|
||||
/** Return seated relay time point if the message has been relayed */
|
||||
std::optional<Stopwatch::time_point>
|
||||
relayed() const
|
||||
@@ -175,20 +170,6 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
shouldProcessForPeer(
|
||||
PeerShortID peer,
|
||||
Stopwatch::time_point now,
|
||||
std::chrono::seconds interval)
|
||||
{
|
||||
if (peerProcessed_.contains(peer) && ((peerProcessed_[peer] + interval) > now))
|
||||
return false;
|
||||
// Peer may already be in the list, but adding it again doesn't hurt
|
||||
addPeer(peer);
|
||||
peerProcessed_[peer] = now;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
HashRouterFlags flags_ = HashRouterFlags::UNDEFINED;
|
||||
std::set<PeerShortID> peers_;
|
||||
@@ -196,7 +177,6 @@ private:
|
||||
// than one flag needs to expire independently.
|
||||
std::optional<Stopwatch::time_point> relayed_;
|
||||
std::optional<Stopwatch::time_point> processed_;
|
||||
std::map<PeerShortID, Stopwatch::time_point> peerProcessed_;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -219,7 +199,7 @@ public:
|
||||
|
||||
/** Add a suppression peer and get message's relay status.
|
||||
* Return pair:
|
||||
* element 1: true if the key is added.
|
||||
* element 1: true if the peer is added.
|
||||
* element 2: optional is seated to the relay time point or
|
||||
* is unseated if has not relayed yet. */
|
||||
std::pair<bool, std::optional<Stopwatch::time_point>>
|
||||
@@ -236,15 +216,6 @@ public:
|
||||
HashRouterFlags& flags,
|
||||
std::chrono::seconds tx_interval);
|
||||
|
||||
/** Determines whether the hashed item should be processed for the given
|
||||
peer. Could be an incoming or outgoing message.
|
||||
|
||||
Items filtered with this function should only be processed for the given
|
||||
peer once. Unlike shouldProcess, it can be processed for other peers.
|
||||
*/
|
||||
bool
|
||||
shouldProcessForPeer(uint256 const& key, PeerShortID peer, std::chrono::seconds interval);
|
||||
|
||||
/** Set the flags on a hash.
|
||||
|
||||
@return `true` if the flags were changed. `false` if unchanged.
|
||||
@@ -270,11 +241,6 @@ public:
|
||||
std::optional<std::set<PeerShortID>>
|
||||
shouldRelay(uint256 const& key);
|
||||
|
||||
/** Returns a copy of the set of peers in the Entry for the key
|
||||
*/
|
||||
std::set<PeerShortID>
|
||||
getPeers(uint256 const& key);
|
||||
|
||||
private:
|
||||
// pair.second indicates whether the entry was created
|
||||
std::pair<Entry&, bool>
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
beast::Journal journal,
|
||||
Logs& logs,
|
||||
perf::PerfLog& perfLog);
|
||||
~JobQueue() override;
|
||||
~JobQueue();
|
||||
|
||||
/** Adds a job to the JobQueue.
|
||||
|
||||
@@ -141,7 +141,8 @@ public:
|
||||
*/
|
||||
template <
|
||||
typename JobHandler,
|
||||
typename = std::enable_if_t<std::is_same_v<decltype(std::declval<JobHandler&&>()()), void>>>
|
||||
typename =
|
||||
std::enable_if_t<std::is_same<decltype(std::declval<JobHandler&&>()()), void>::value>>
|
||||
bool
|
||||
addJob(JobType type, std::string const& name, JobHandler&& jobHandler)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include <xrpl/beast/insight/Collector.h>
|
||||
#include <xrpl/core/JobTypeInfo.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
struct JobTypeData
|
||||
@@ -35,9 +33,9 @@ public:
|
||||
|
||||
JobTypeData(
|
||||
JobTypeInfo const& info_,
|
||||
beast::insight::Collector::ptr collector,
|
||||
beast::insight::Collector::ptr const& collector,
|
||||
Logs& logs) noexcept
|
||||
: m_load(logs.journal("LoadMonitor")), m_collector(std::move(collector)), info(info_)
|
||||
: m_load(logs.journal("LoadMonitor")), m_collector(collector), info(info_)
|
||||
|
||||
{
|
||||
m_load.setTargetLatency(info.getAverageLatency(), info.getPeakLatency());
|
||||
|
||||
@@ -16,7 +16,7 @@ class LoadEvent
|
||||
{
|
||||
public:
|
||||
// VFALCO TODO remove the dependency on LoadMonitor. Is that possible?
|
||||
LoadEvent(LoadMonitor& monitor, std::string name, bool shouldStart);
|
||||
LoadEvent(LoadMonitor& monitor, std::string const& name, bool shouldStart);
|
||||
LoadEvent(LoadEvent const&) = delete;
|
||||
|
||||
~LoadEvent();
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
explicit Workers(
|
||||
Callback& callback,
|
||||
perf::PerfLog* perfLog,
|
||||
std::string threadNames = "Worker",
|
||||
std::string const& threadNames = "Worker",
|
||||
int numberOfThreads = static_cast<int>(std::thread::hardware_concurrency()));
|
||||
|
||||
~Workers();
|
||||
@@ -164,7 +164,7 @@ private:
|
||||
public beast::LockFreeStack<Worker, PausedTag>::Node
|
||||
{
|
||||
public:
|
||||
Worker(Workers& workers, std::string threadName, int const instance);
|
||||
Worker(Workers& workers, std::string const& threadName, int const instance);
|
||||
|
||||
~Worker();
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ class Value;
|
||||
class WriterBase
|
||||
{
|
||||
public:
|
||||
virtual ~WriterBase() = default;
|
||||
virtual ~WriterBase()
|
||||
{
|
||||
}
|
||||
virtual std::string
|
||||
write(Value const& root) = 0;
|
||||
};
|
||||
@@ -32,7 +34,9 @@ class FastWriter : public WriterBase
|
||||
{
|
||||
public:
|
||||
FastWriter() = default;
|
||||
~FastWriter() override = default;
|
||||
virtual ~FastWriter()
|
||||
{
|
||||
}
|
||||
|
||||
public: // overridden from Writer
|
||||
std::string
|
||||
@@ -67,7 +71,9 @@ class StyledWriter : public WriterBase
|
||||
{
|
||||
public:
|
||||
StyledWriter();
|
||||
~StyledWriter() override = default;
|
||||
virtual ~StyledWriter()
|
||||
{
|
||||
}
|
||||
|
||||
public: // overridden from Writer
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a>
|
||||
@@ -130,7 +136,9 @@ class StyledStreamWriter
|
||||
{
|
||||
public:
|
||||
StyledStreamWriter(std::string indentation = "\t");
|
||||
~StyledStreamWriter() = default;
|
||||
~StyledStreamWriter()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <xrpl/shamap/SHAMap.h>
|
||||
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
@@ -24,8 +23,8 @@ public:
|
||||
struct FeatureInfo
|
||||
{
|
||||
FeatureInfo() = delete;
|
||||
FeatureInfo(std::string n, uint256 const& f, VoteBehavior v)
|
||||
: name(std::move(n)), feature(f), vote(v)
|
||||
FeatureInfo(std::string const& n, uint256 const& f, VoteBehavior v)
|
||||
: name(n), feature(f), vote(v)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ class BookListeners
|
||||
public:
|
||||
using pointer = std::shared_ptr<BookListeners>;
|
||||
|
||||
BookListeners() = default;
|
||||
BookListeners()
|
||||
{
|
||||
}
|
||||
|
||||
/** Add a new subscription for this book
|
||||
*/
|
||||
|
||||
@@ -132,7 +132,7 @@ template <class Base>
|
||||
class CachedView : public detail::CachedViewImpl
|
||||
{
|
||||
private:
|
||||
static_assert(std::is_base_of_v<DigestAwareReadView, Base>, "");
|
||||
static_assert(std::is_base_of<DigestAwareReadView, Base>::value, "");
|
||||
|
||||
std::shared_ptr<Base const> sp_;
|
||||
|
||||
|
||||
@@ -82,12 +82,12 @@ public:
|
||||
*/
|
||||
Ledger(
|
||||
create_genesis_t,
|
||||
Rules rules,
|
||||
Rules const& rules,
|
||||
Fees const& fees,
|
||||
std::vector<uint256> const& amendments,
|
||||
Family& family);
|
||||
|
||||
Ledger(LedgerHeader const& info, Rules rules, Family& family);
|
||||
Ledger(LedgerHeader const& info, Rules const& rules, Family& family);
|
||||
|
||||
/** Used for ledgers loaded from JSON files
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
LedgerHeader const& info,
|
||||
bool& loaded,
|
||||
bool acquire,
|
||||
Rules rules,
|
||||
Rules const& rules,
|
||||
Fees const& fees,
|
||||
Family& family,
|
||||
beast::Journal j);
|
||||
@@ -117,11 +117,11 @@ public:
|
||||
Ledger(
|
||||
std::uint32_t ledgerSeq,
|
||||
NetClock::time_point closeTime,
|
||||
Rules rules,
|
||||
Rules const& rules,
|
||||
Fees const& fees,
|
||||
Family& family);
|
||||
|
||||
~Ledger() override = default;
|
||||
~Ledger() = default;
|
||||
|
||||
//
|
||||
// ReadView
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
OpenView(
|
||||
open_ledger_t,
|
||||
ReadView const* base,
|
||||
Rules rules,
|
||||
Rules const& rules,
|
||||
std::shared_ptr<void const> hold = nullptr);
|
||||
|
||||
OpenView(open_ledger_t, Rules const& rules, std::shared_ptr<ReadView const> const& base)
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
@@ -64,8 +63,8 @@ private:
|
||||
public:
|
||||
struct AdjustmentIOU
|
||||
{
|
||||
AdjustmentIOU(STAmount d, STAmount c, STAmount b)
|
||||
: debits(std::move(d)), credits(std::move(c)), origBalance(std::move(b))
|
||||
AdjustmentIOU(STAmount const& d, STAmount const& c, STAmount const& b)
|
||||
: debits(d), credits(c), origBalance(b)
|
||||
{
|
||||
}
|
||||
STAmount debits;
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace xrpl::detail {
|
||||
namespace xrpl {
|
||||
namespace detail {
|
||||
|
||||
// Helper class that buffers modifications
|
||||
class ApplyStateTable
|
||||
@@ -124,4 +125,5 @@ private:
|
||||
beast::Journal j);
|
||||
};
|
||||
|
||||
} // namespace xrpl::detail
|
||||
} // namespace detail
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include <xrpl/ledger/detail/ApplyStateTable.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
|
||||
namespace xrpl::detail {
|
||||
namespace xrpl {
|
||||
namespace detail {
|
||||
|
||||
class ApplyViewBase : public ApplyView, public RawView
|
||||
{
|
||||
@@ -101,4 +102,5 @@ protected:
|
||||
detail::ApplyStateTable items_;
|
||||
};
|
||||
|
||||
} // namespace xrpl::detail
|
||||
} // namespace detail
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl::detail {
|
||||
namespace xrpl {
|
||||
namespace detail {
|
||||
|
||||
// Helper class that buffers raw modifications
|
||||
class RawStateTable
|
||||
@@ -107,4 +108,5 @@ private:
|
||||
XRPAmount dropsDestroyed_{0};
|
||||
};
|
||||
|
||||
} // namespace xrpl::detail
|
||||
} // namespace detail
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/nft.h>
|
||||
|
||||
#include <utility>
|
||||
namespace xrpl {
|
||||
|
||||
namespace xrpl::nft {
|
||||
namespace nft {
|
||||
|
||||
/** Delete up to a specified number of offers from the specified token offer
|
||||
* directory. */
|
||||
@@ -30,8 +30,8 @@ struct TokenAndPage
|
||||
STObject token;
|
||||
std::shared_ptr<SLE> page;
|
||||
|
||||
TokenAndPage(STObject token_, std::shared_ptr<SLE> page_)
|
||||
: token(std::move(token_)), page(std::move(page_))
|
||||
TokenAndPage(STObject const& token_, std::shared_ptr<SLE> page_)
|
||||
: token(token_), page(std::move(page_))
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -136,4 +136,6 @@ checkTrustlineDeepFrozen(
|
||||
beast::Journal const j,
|
||||
Issue const& issue);
|
||||
|
||||
} // namespace xrpl::nft
|
||||
} // namespace nft
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include <xrpl/ledger/View.h>
|
||||
|
||||
namespace xrpl::permissioned_dex {
|
||||
namespace xrpl {
|
||||
namespace permissioned_dex {
|
||||
|
||||
// Check if an account is in a permissioned domain
|
||||
[[nodiscard]] bool
|
||||
@@ -15,4 +16,6 @@ offerInDomain(
|
||||
Domain const& domainID,
|
||||
beast::Journal j);
|
||||
|
||||
} // namespace xrpl::permissioned_dex
|
||||
} // namespace permissioned_dex
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -79,8 +79,8 @@ public:
|
||||
template <
|
||||
class T,
|
||||
class = std::enable_if_t<
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>>>
|
||||
std::is_same<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>::value ||
|
||||
std::is_same<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>::value>>
|
||||
boost::system::error_code
|
||||
preConnectVerify(T& strm, std::string const& host)
|
||||
{
|
||||
@@ -99,8 +99,8 @@ public:
|
||||
template <
|
||||
class T,
|
||||
class = std::enable_if_t<
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
|
||||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>>>
|
||||
std::is_same<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>::value ||
|
||||
std::is_same<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>::value>>
|
||||
/**
|
||||
* @brief invoked after connect/async_connect but before sending data
|
||||
* on an ssl stream - to setup name verification.
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
/** A backend used for the NodeStore.
|
||||
|
||||
@@ -139,4 +140,5 @@ public:
|
||||
fdRequired() const = 0;
|
||||
};
|
||||
|
||||
} // namespace xrpl::NodeStore
|
||||
} // namespace NodeStore
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
#include <condition_variable>
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
namespace xrpl {
|
||||
|
||||
namespace NodeStore {
|
||||
|
||||
/** Persistency layer for NodeObject
|
||||
|
||||
@@ -272,4 +274,5 @@ private:
|
||||
threadEntry();
|
||||
};
|
||||
|
||||
} // namespace xrpl::NodeStore
|
||||
} // namespace NodeStore
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
#include <xrpl/nodestore/Database.h>
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
/* This class has two key-value store Backend objects for persisting SHAMap
|
||||
* records. This facilitates online deletion of data. New backends are
|
||||
@@ -35,4 +36,5 @@ public:
|
||||
f) = 0;
|
||||
};
|
||||
|
||||
} // namespace xrpl::NodeStore
|
||||
} // namespace NodeStore
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
#include <xrpl/nodestore/Scheduler.h>
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
/** Simple NodeStore Scheduler that just performs the tasks synchronously. */
|
||||
class DummyScheduler : public Scheduler
|
||||
{
|
||||
public:
|
||||
DummyScheduler() = default;
|
||||
~DummyScheduler() override = default;
|
||||
~DummyScheduler() = default;
|
||||
void
|
||||
scheduleTask(Task& task) override;
|
||||
void
|
||||
@@ -18,4 +19,5 @@ public:
|
||||
onBatchWrite(BatchWriteReport const& report) override;
|
||||
};
|
||||
|
||||
} // namespace xrpl::NodeStore
|
||||
} // namespace NodeStore
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
#include <nudb/store.hpp>
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
namespace xrpl {
|
||||
|
||||
namespace NodeStore {
|
||||
|
||||
/** Base class for backend factories. */
|
||||
class Factory
|
||||
@@ -57,4 +59,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::NodeStore
|
||||
} // namespace NodeStore
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include <xrpl/nodestore/DatabaseRotating.h>
|
||||
#include <xrpl/nodestore/Factory.h>
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
namespace xrpl {
|
||||
|
||||
namespace NodeStore {
|
||||
|
||||
/** Singleton for managing NodeStore factories and back ends. */
|
||||
class Manager
|
||||
@@ -79,4 +81,5 @@ public:
|
||||
beast::Journal journal) = 0;
|
||||
};
|
||||
|
||||
} // namespace xrpl::NodeStore
|
||||
} // namespace NodeStore
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
enum class FetchType { synchronous, async };
|
||||
|
||||
@@ -63,4 +64,5 @@ public:
|
||||
onBatchWrite(BatchWriteReport const& report) = 0;
|
||||
};
|
||||
|
||||
} // namespace xrpl::NodeStore
|
||||
} // namespace NodeStore
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
/** Derived classes perform scheduled tasks. */
|
||||
struct Task
|
||||
@@ -14,4 +15,5 @@ struct Task
|
||||
performScheduledTask() = 0;
|
||||
};
|
||||
|
||||
} // namespace xrpl::NodeStore
|
||||
} // namespace NodeStore
|
||||
} // namespace xrpl
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user