diff --git a/Builds/VisualStudio2012/beast.vcxproj b/Builds/VisualStudio2012/beast.vcxproj index ee11c79c21..e8a152c307 100644 --- a/Builds/VisualStudio2012/beast.vcxproj +++ b/Builds/VisualStudio2012/beast.vcxproj @@ -110,9 +110,12 @@ + + + @@ -136,22 +139,11 @@ - - - - - - - - - - - @@ -165,10 +157,7 @@ - - - @@ -185,6 +174,7 @@ + @@ -265,19 +255,15 @@ - - - - @@ -299,24 +285,16 @@ - - - - - - - - @@ -363,7 +341,6 @@ - @@ -391,14 +368,6 @@ - - - - - - - - @@ -446,6 +415,12 @@ true + + true + true + true + true + true true @@ -476,6 +451,12 @@ true true + + true + true + true + true + true @@ -814,12 +795,6 @@ true - - true - true - true - true - true true @@ -938,12 +913,6 @@ true true - - true - true - true - true - true true @@ -1244,12 +1213,6 @@ true true - - true - true - true - true - true true @@ -1376,27 +1339,6 @@ true true - - - true - true - true - true - - - true - true - true - true - - - - true - true - true - true - - true diff --git a/Builds/VisualStudio2012/beast.vcxproj.filters b/Builds/VisualStudio2012/beast.vcxproj.filters index aa2c106050..0b081079a1 100644 --- a/Builds/VisualStudio2012/beast.vcxproj.filters +++ b/Builds/VisualStudio2012/beast.vcxproj.filters @@ -68,10 +68,10 @@ beast_core - beast\http\crypto\impl\sha2 + beast\crypto\impl\sha2 - beast\http\crypto\impl\sha2 + beast\crypto\impl\sha2 scripts @@ -135,18 +135,6 @@ {69e28551-92ea-420b-a465-75ed248e3b59} - - {62b1f8e3-79e4-46cc-b3fb-a12754aef249} - - - {1170f2bc-2456-410a-ab2b-c45f6ed37b9e} - - - {4834218f-f13f-41bc-a8a0-50314a3a99a3} - - - {15a98fee-1b52-45eb-9480-514b8750d755} - {cbf5f5a3-5d66-4b6d-996d-20ed14b41793} @@ -195,12 +183,6 @@ {91538dcf-b219-4c80-9861-bb4949089775} - - {2f5b95a8-1adf-4319-8464-ddc2b2e03f0b} - - - {bf498396-2e1f-4903-be68-3053ba439af5} - {c0724499-ab69-40c3-90e2-65242dbd2eaa} @@ -294,15 +276,6 @@ {30b0fdfb-02b6-47dd-bdd9-ffc1f57e1f2c} - - {9c1ef4c4-5623-4500-859f-12d6ce5ae362} - - - {fc3d3f14-9ba1-43e4-b086-cbbd2f63b944} - - - {44489531-f44a-439a-a6ea-d32c252b1e8b} - {df4f2935-13a1-4afe-90cc-d86472ec2466} @@ -315,14 +288,20 @@ {04f27818-7843-4ef3-967c-1761dc892342} + + {9c1ef4c4-5623-4500-859f-12d6ce5ae362} + + + {fc3d3f14-9ba1-43e4-b086-cbbd2f63b944} + + + {44489531-f44a-439a-a6ea-d32c252b1e8b} + beast_core - - beast_core\containers - beast_core\containers @@ -350,9 +329,6 @@ beast_core\containers - - beast_core\containers - beast_core\containers @@ -392,9 +368,6 @@ beast_core\maths - - beast_core\maths - beast_core\maths @@ -407,9 +380,6 @@ beast_core\memory - - beast_core\memory - beast_core\misc @@ -575,21 +545,6 @@ beast_core\memory - - beast_core\memory - - - beast_core\memory - - - beast_core\memory - - - beast_core\memory - - - beast_core\containers - beast_core\threads @@ -599,33 +554,15 @@ beast_core\diagnostic - - beast_core\maths - beast_core\diagnostic - - beast_crypto - - - beast_core\containers - beast_core\files beast_core\diagnostic - - beast_core\memory - - - beast_db - - - beast_db\keyvalue - beast_sqlite @@ -731,9 +668,6 @@ beast_core\thread - - beast_core\thread - beast_core\thread @@ -752,12 +686,6 @@ beast_asio\system - - beast_extras\traits - - - beast_extras - beast_core\system @@ -776,30 +704,6 @@ beast_core\system - - beast\intrusive - - - beast\intrusive - - - beast\mpl - - - beast\mpl - - - beast\mpl - - - beast\mpl - - - beast\mpl - - - beast\mpl - beast_asio\async @@ -914,9 +818,6 @@ beast_asio\http - - beast\mpl - beast_asio\basics @@ -932,15 +833,6 @@ beast_core\diagnostic - - beast_crypto\math - - - beast_crypto\math - - - beast_crypto\math - beast_core\memory @@ -1004,12 +896,6 @@ beast\intrusive - - beast\intrusive - - - beast\mpl - beast\http\impl\http-parser @@ -1091,17 +977,14 @@ beast - - beast\intrusive - beast - beast\http\crypto\impl\sha2 + beast\crypto\impl\sha2 - beast\http\crypto + beast\crypto beast_asio\async @@ -1273,23 +1156,14 @@ beast\asio - beast\http\crypto + beast\crypto beast\smart_ptr - - beast\stl - beast\stl - - beast\stl - - - beast\stl - beast @@ -1338,11 +1212,23 @@ beast + + beast\threads + + + beast\intrusive + + + beast\crypto + + + beast\crypto + + + beast\crypto + - - beast_core\containers - beast_core\containers @@ -1385,9 +1271,6 @@ beast_core\maths - - beast_core\maths - beast_core\maths @@ -1589,12 +1472,6 @@ beast_core\diagnostic - - beast_db - - - beast_db\keyvalue - beast_sqlite @@ -1652,9 +1529,6 @@ beast_core\thread - - beast_core\thread - beast_core\thread @@ -1733,9 +1607,6 @@ beast_asio\http - - beast_crypto - beast_core @@ -1751,15 +1622,6 @@ beast_core\diagnostic - - beast_crypto\math - - - beast_crypto\math - - - beast_extras - beast\net @@ -1806,19 +1668,19 @@ beast\http\impl - beast\http\crypto\impl\sha2 + beast\crypto\impl\sha2 - beast\http\crypto\impl\sha2 + beast\crypto\impl\sha2 - beast\http\crypto\impl\sha2 + beast\crypto\impl\sha2 - beast\http\crypto + beast\crypto - beast\http\crypto\impl + beast\crypto\impl beast\chrono\impl @@ -1890,7 +1752,7 @@ beast\asio\impl - beast\http\crypto\impl + beast\crypto\impl beast\smart_ptr\impl @@ -1916,6 +1778,12 @@ beast\insight\impl + + beast\crypto\impl + + + beast\crypto\impl + diff --git a/TODO.txt b/TODO.txt index 965d1721e4..32bdb06ae4 100644 --- a/TODO.txt +++ b/TODO.txt @@ -52,8 +52,6 @@ BEAST TODO - Rename include guards to boost style, e.g. BEAST_THROW_H_INCLUDED -- Decide if we should get rid of AtomicCounter, AtomicFlag, AtomicPointer, AtomicState - - Clean up CacheLine, StaticObject - Clean up ConcurrentObject diff --git a/beast/Crypto.h b/beast/Crypto.h index 379e172e3b..c84425be51 100644 --- a/beast/Crypto.h +++ b/beast/Crypto.h @@ -20,8 +20,11 @@ #ifndef BEAST_CRYPTO_H_INCLUDED #define BEAST_CRYPTO_H_INCLUDED +#include "crypto/BinaryEncoding.h" #include "crypto/MurmurHash.h" #include "crypto/Sha256.h" +#include "crypto/UnsignedInteger.h" +#include "crypto/UnsignedIntegerCalc.h" #endif diff --git a/beast/FixedArray.h b/beast/FixedArray.h index e9d50488af..c82062f8ac 100644 --- a/beast/FixedArray.h +++ b/beast/FixedArray.h @@ -139,7 +139,8 @@ bool operator!= (FixedArray const& lhs, FixedArray const& rhs) template bool operator< (FixedArray const& lhs, FixedArray const& rhs) { - return std::lexicographical_compare (lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + return std::lexicographical_compare ( + lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } template diff --git a/beast/Intrusive.h b/beast/Intrusive.h index 065b92c9dd..89a3ace3bd 100644 --- a/beast/Intrusive.h +++ b/beast/Intrusive.h @@ -20,8 +20,6 @@ #ifndef BEAST_INTRUSIVE_H_INCLUDED #define BEAST_INTRUSIVE_H_INCLUDED -#include "intrusive/ForwardList.h" -#include "intrusive/IntrusiveArray.h" #include "intrusive/List.h" #include "intrusive/LockFreeStack.h" diff --git a/beast/MPL.h b/beast/MPL.h index 3be24c673a..cd4d3eadeb 100644 --- a/beast/MPL.h +++ b/beast/MPL.h @@ -20,14 +20,6 @@ #ifndef BEAST_MPL_H_INCLUDED #define BEAST_MPL_H_INCLUDED -#include "mpl/AddConst.h" -#include "mpl/CopyConst.h" -#include "mpl/IfCond.h" #include "mpl/IsCallPossible.h" -#include "mpl/PointerToOther.h" -#include "mpl/RemoveConst.h" -#include "mpl/RemoveConstVolatile.h" -#include "mpl/RemoveReference.h" -#include "mpl/RemoveVolatile.h" #endif diff --git a/beast/STL.h b/beast/STL.h index 3a84b3486e..730eb22ebf 100644 --- a/beast/STL.h +++ b/beast/STL.h @@ -20,9 +20,6 @@ #ifndef BEAST_STL_H_INCLUDED #define BEAST_STL_H_INCLUDED -#include "stl/function.h" #include "stl/shared_ptr.h" -#include "stl/thread.h" -#include "stl/unique_ptr.h" #endif diff --git a/beast/Threads.h b/beast/Threads.h index 6c3859d9a6..bd7a9c814c 100644 --- a/beast/Threads.h +++ b/beast/Threads.h @@ -34,4 +34,6 @@ #include "threads/WaitableEvent.h" #include "threads/ScopedWrapperContext.h" +#include "threads/semaphore.h" + #endif diff --git a/modules/beast_crypto/math/BinaryEncoding.h b/beast/crypto/BinaryEncoding.h similarity index 99% rename from modules/beast_crypto/math/BinaryEncoding.h rename to beast/crypto/BinaryEncoding.h index d93691e4a7..0112160eb9 100644 --- a/modules/beast_crypto/math/BinaryEncoding.h +++ b/beast/crypto/BinaryEncoding.h @@ -20,5 +20,4 @@ #ifndef BEAST_CRYPTO_BINARYENCODING_H_INCLUDED #define BEAST_CRYPTO_BINARYENCODING_H_INCLUDED - #endif diff --git a/beast/crypto/Crypto.cpp b/beast/crypto/Crypto.cpp index 77a73390f9..5fa107022a 100644 --- a/beast/crypto/Crypto.cpp +++ b/beast/crypto/Crypto.cpp @@ -19,5 +19,9 @@ #include "BeastConfig.h" +#include "../../modules/beast_core/beast_core.h" // for UnitTest + +#include "impl/BinaryEncoding.cpp" #include "impl/MurmurHash.cpp" #include "impl/Sha256.cpp" +#include "impl/UnsignedInteger.cpp" diff --git a/modules/beast_crypto/math/UnsignedInteger.h b/beast/crypto/UnsignedInteger.h similarity index 96% rename from modules/beast_crypto/math/UnsignedInteger.h rename to beast/crypto/UnsignedInteger.h index 7756d584fe..09a87c74fe 100644 --- a/modules/beast_crypto/math/UnsignedInteger.h +++ b/beast/crypto/UnsignedInteger.h @@ -20,6 +20,15 @@ #ifndef BEAST_CRYPTO_UNSIGNEDINTEGER_H_INCLUDED #define BEAST_CRYPTO_UNSIGNEDINTEGER_H_INCLUDED +#include "../SafeBool.h" +#include "UnsignedIntegerCalc.h" +#include "MurmurHash.h" + +#include +#include + +namespace beast { + /** Represents a set of bits of fixed size. The data is stored in "canonical" format which is network (big endian) @@ -36,13 +45,13 @@ public: static std::size_t const size = Bytes; // The underlying integer type we use when converting to calculation format. - typedef uint32 IntCalcType; + typedef std::uint32_t IntCalcType; // The type of object resulting from a conversion to calculation format. typedef UnsignedIntegerCalc CalcType; // Standard container compatibility - typedef uint8 value_type; + typedef std::uint8_t value_type; typedef value_type* iterator; typedef value_type const* const_iterator; @@ -135,7 +144,8 @@ public: template static UnsignedInteger createFromInteger (UnsignedIntegralType value) { - static_bassert (Bytes >= sizeof (UnsignedIntegralType)); + static_assert (Bytes >= sizeof (UnsignedIntegralType), + "Bytes is too small."); UnsignedInteger result; value = toNetworkByteOrder (value); result.clear (); @@ -296,4 +306,6 @@ private: IntCalcType m_values [CalcCount]; }; +} + #endif diff --git a/modules/beast_crypto/math/UnsignedIntegerCalc.h b/beast/crypto/UnsignedIntegerCalc.h similarity index 98% rename from modules/beast_crypto/math/UnsignedIntegerCalc.h rename to beast/crypto/UnsignedIntegerCalc.h index 5bb7f0f4f6..de3ea63d7e 100644 --- a/modules/beast_crypto/math/UnsignedIntegerCalc.h +++ b/beast/crypto/UnsignedIntegerCalc.h @@ -20,22 +20,25 @@ #ifndef BEAST_CRYPTO_UNSIGNEDINTEGERCALC_H_INCLUDED #define BEAST_CRYPTO_UNSIGNEDINTEGERCALC_H_INCLUDED -namespace detail -{ +#include + +namespace beast { + +namespace detail { template struct DoubleWidthUInt; template <> -struct DoubleWidthUInt +struct DoubleWidthUInt { - typedef uint32 type; + typedef std::uint32_t type; }; template <> -struct DoubleWidthUInt +struct DoubleWidthUInt { - typedef uint64 type; + typedef std::uint64_t type; }; } @@ -427,4 +430,6 @@ private: UInt* m_values; }; +} + #endif diff --git a/modules/beast_crypto/math/BinaryEncoding.cpp b/beast/crypto/impl/BinaryEncoding.cpp similarity index 98% rename from modules/beast_crypto/math/BinaryEncoding.cpp rename to beast/crypto/impl/BinaryEncoding.cpp index 198a6b7b86..dfdca1bcd6 100644 --- a/modules/beast_crypto/math/BinaryEncoding.cpp +++ b/beast/crypto/impl/BinaryEncoding.cpp @@ -17,6 +17,14 @@ */ //============================================================================== +#include "../BinaryEncoding.h" +#include "../UnsignedInteger.h" + +#include +#include + +namespace beast { + /** Generic algorithms for base encoding and decoding. */ class BinaryEncoding { @@ -393,3 +401,5 @@ public: }; static BinaryEncodingTests BinaryEncodingTests; + +} diff --git a/modules/beast_crypto/math/UnsignedInteger.cpp b/beast/crypto/impl/UnsignedInteger.cpp similarity index 96% rename from modules/beast_crypto/math/UnsignedInteger.cpp rename to beast/crypto/impl/UnsignedInteger.cpp index 40b079d061..2cd246257c 100644 --- a/modules/beast_crypto/math/UnsignedInteger.cpp +++ b/beast/crypto/impl/UnsignedInteger.cpp @@ -3,6 +3,10 @@ This file is part of Beast: https://github.com/vinniefalco/Beast Copyright 2013, Vinnie Falco + Portions are Copyright (c) 2013 the authors listed at the following URL, + and/or the authors of referenced articles or incorporated external code: + http://en.literateprograms.org/Arbitrary-precision_integer_arithmetic_(C)?action=history&offset=20100923155004 + 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. @@ -17,7 +21,13 @@ */ //============================================================================== -//------------------------------------------------------------------------------ +#include "../UnsignedInteger.h" + +namespace beast { + +namespace multiprecsion { + +#if 0 /* Copyright (c) 2013 the authors listed at the following URL, and/or the authors of referenced articles or incorporated external code: @@ -41,15 +51,11 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Retrieved from: http://en.literateprograms.org/Arbitrary-precision_integer_arithmetic_(C)?oldid=16902 */ -namespace multiprecsion -{ - -#if 0 -//------------------------------------------------------------------------------ +// +// Retrieved from: http://en.literateprograms.org/Arbitrary-precision_integer_arithmetic_(C)?oldid=16902 +// typedef unsigned short component_t; typedef unsigned long double_component_t; @@ -394,3 +400,5 @@ private: }; static UnsignedIntegerTests unsignedIntegerTests; + +} diff --git a/beast/insight/Collector.h b/beast/insight/Collector.h index da923d5fe5..9d379307cc 100644 --- a/beast/insight/Collector.h +++ b/beast/insight/Collector.h @@ -20,8 +20,7 @@ #ifndef BEAST_INSIGHT_COLLECTOR_H_INCLUDED #define BEAST_INSIGHT_COLLECTOR_H_INCLUDED -#include "../stl/function.h" -#include "../stl/shared_ptr.h" +#include #include "Counter.h" #include "Event.h" diff --git a/beast/insight/Counter.h b/beast/insight/Counter.h index ecffa911e9..4e78013384 100644 --- a/beast/insight/Counter.h +++ b/beast/insight/Counter.h @@ -20,9 +20,9 @@ #ifndef BEAST_INSIGHT_COUNTER_H_INCLUDED #define BEAST_INSIGHT_COUNTER_H_INCLUDED -#include "CounterImpl.h" +#include -#include "../stl/shared_ptr.h" +#include "CounterImpl.h" namespace beast { namespace insight { @@ -52,7 +52,7 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Counter (shared_ptr const& impl) + explicit Counter (std::shared_ptr const& impl) : m_impl (impl) { } @@ -100,7 +100,7 @@ public: /** @} */ private: - shared_ptr m_impl; + std::shared_ptr m_impl; }; } diff --git a/beast/insight/CounterImpl.h b/beast/insight/CounterImpl.h index 047a988198..963151490c 100644 --- a/beast/insight/CounterImpl.h +++ b/beast/insight/CounterImpl.h @@ -20,16 +20,19 @@ #ifndef BEAST_INSIGHT_COUNTERIMPL_H_INCLUDED #define BEAST_INSIGHT_COUNTERIMPL_H_INCLUDED +#include +#include + namespace beast { namespace insight { class Counter; -class CounterImpl : public enable_shared_from_this +class CounterImpl : public std::enable_shared_from_this { public: typedef int64 value_type; - typedef beast::function HandlerType; + typedef std::function HandlerType; virtual ~CounterImpl () = 0; virtual void increment (value_type amount) = 0; diff --git a/beast/insight/Event.h b/beast/insight/Event.h index a892c780b6..7c822fed7e 100644 --- a/beast/insight/Event.h +++ b/beast/insight/Event.h @@ -20,9 +20,9 @@ #ifndef BEAST_INSIGHT_EVENT_H_INCLUDED #define BEAST_INSIGHT_EVENT_H_INCLUDED -#include "EventImpl.h" +#include -#include "../stl/shared_ptr.h" +#include "EventImpl.h" namespace beast { namespace insight { @@ -53,7 +53,7 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Event (shared_ptr const& impl) + explicit Event (std::shared_ptr const& impl) : m_impl (impl) { } @@ -69,7 +69,7 @@ public: } private: - shared_ptr m_impl; + std::shared_ptr m_impl; }; } diff --git a/beast/insight/EventImpl.h b/beast/insight/EventImpl.h index ef93a2334c..3e84fe4260 100644 --- a/beast/insight/EventImpl.h +++ b/beast/insight/EventImpl.h @@ -20,12 +20,14 @@ #ifndef BEAST_INSIGHT_EVENTIMPL_H_INCLUDED #define BEAST_INSIGHT_EVENTIMPL_H_INCLUDED +#include + namespace beast { namespace insight { class Event; -class EventImpl : public enable_shared_from_this +class EventImpl : public std::enable_shared_from_this { public: typedef uint64 value_type; diff --git a/beast/insight/Gauge.h b/beast/insight/Gauge.h index 16fc484fd1..70fff9b05d 100644 --- a/beast/insight/Gauge.h +++ b/beast/insight/Gauge.h @@ -20,9 +20,9 @@ #ifndef BEAST_INSIGHT_GAUGE_H_INCLUDED #define BEAST_INSIGHT_GAUGE_H_INCLUDED -#include "GaugeImpl.h" +#include -#include "../stl/shared_ptr.h" +#include "GaugeImpl.h" namespace beast { namespace insight { @@ -54,7 +54,7 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Gauge (shared_ptr const& impl) + explicit Gauge (std::shared_ptr const& impl) : m_impl (impl) { } @@ -118,7 +118,7 @@ public: /** @} */ private: - shared_ptr m_impl; + std::shared_ptr m_impl; }; } diff --git a/beast/insight/GaugeImpl.h b/beast/insight/GaugeImpl.h index 0e26cb47e5..50ff9b5866 100644 --- a/beast/insight/GaugeImpl.h +++ b/beast/insight/GaugeImpl.h @@ -25,12 +25,12 @@ namespace insight { class Gauge; -class GaugeImpl : public enable_shared_from_this +class GaugeImpl : public std::enable_shared_from_this { public: typedef uint64 value_type; typedef int64 difference_type; - typedef beast::function HandlerType; + typedef std::function HandlerType; virtual ~GaugeImpl () = 0; virtual void set (value_type value) = 0; diff --git a/beast/insight/Hook.h b/beast/insight/Hook.h index 06ef844907..3b45992e3a 100644 --- a/beast/insight/Hook.h +++ b/beast/insight/Hook.h @@ -42,13 +42,13 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Hook (shared_ptr const& impl) + explicit Hook (std::shared_ptr const& impl) : m_impl (impl) { } private: - shared_ptr m_impl; + std::shared_ptr m_impl; }; } diff --git a/beast/insight/HookImpl.h b/beast/insight/HookImpl.h index cbbf371849..6c8cda2a0e 100644 --- a/beast/insight/HookImpl.h +++ b/beast/insight/HookImpl.h @@ -20,16 +20,17 @@ #ifndef BEAST_INSIGHT_HOOKIMPL_H_INCLUDED #define BEAST_INSIGHT_HOOKIMPL_H_INCLUDED -#include "../stl/shared_ptr.h" +#include +#include namespace beast { namespace insight { -class HookImpl : public enable_shared_from_this +class HookImpl : public std::enable_shared_from_this { public: - typedef beast::function HandlerType; - + typedef std::function HandlerType; + virtual ~HookImpl () = 0; }; diff --git a/beast/insight/Meter.h b/beast/insight/Meter.h index bf2090c1d9..bc7c72f9b7 100644 --- a/beast/insight/Meter.h +++ b/beast/insight/Meter.h @@ -51,7 +51,7 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Meter (shared_ptr const& impl) + explicit Meter (std::shared_ptr const& impl) : m_impl (impl) { } @@ -89,7 +89,7 @@ public: /** @} */ private: - shared_ptr m_impl; + std::shared_ptr m_impl; }; } diff --git a/beast/insight/MeterImpl.h b/beast/insight/MeterImpl.h index 057bd155dd..ca3fffaa55 100644 --- a/beast/insight/MeterImpl.h +++ b/beast/insight/MeterImpl.h @@ -20,16 +20,19 @@ #ifndef BEAST_INSIGHT_METERIMPL_H_INCLUDED #define BEAST_INSIGHT_METERIMPL_H_INCLUDED +#include +#include + namespace beast { namespace insight { class Meter; -class MeterImpl : public enable_shared_from_this +class MeterImpl : public std::enable_shared_from_this { public: typedef uint64 value_type; - typedef beast::function HandlerType; + typedef std::function HandlerType; virtual ~MeterImpl () = 0; virtual void increment (value_type amount) = 0; diff --git a/beast/insight/NullCollector.h b/beast/insight/NullCollector.h index af1f22d6be..d0b117b2e4 100644 --- a/beast/insight/NullCollector.h +++ b/beast/insight/NullCollector.h @@ -29,7 +29,7 @@ namespace insight { class NullCollector : public Collector { public: - static shared_ptr New (); + static std::shared_ptr New (); }; } diff --git a/beast/insight/StatsDCollector.h b/beast/insight/StatsDCollector.h index 931c478f93..33a8682066 100644 --- a/beast/insight/StatsDCollector.h +++ b/beast/insight/StatsDCollector.h @@ -39,7 +39,7 @@ public: @param prefix A string pre-pended before each metric name. @param journal Destination for logging output. */ - static shared_ptr New (IPAddress const& address, + static std::shared_ptr New (IPAddress const& address, std::string const& prefix, Journal journal); }; diff --git a/beast/insight/impl/NullCollector.cpp b/beast/insight/impl/NullCollector.cpp index f1ab857f65..0539d783a9 100644 --- a/beast/insight/impl/NullCollector.cpp +++ b/beast/insight/impl/NullCollector.cpp @@ -112,27 +112,27 @@ public: Hook make_hook (HookImpl::HandlerType const&) { - return Hook (make_shared ()); + return Hook (std::make_shared ()); } Counter make_counter (std::string const&) { - return Counter (make_shared ()); + return Counter (std::make_shared ()); } Event make_event (std::string const&) { - return Event (make_shared ()); + return Event (std::make_shared ()); } Gauge make_gauge (std::string const&) { - return Gauge (make_shared ()); + return Gauge (std::make_shared ()); } Meter make_meter (std::string const&) { - return Meter (make_shared ()); + return Meter (std::make_shared ()); } }; @@ -140,9 +140,9 @@ public: //------------------------------------------------------------------------------ -shared_ptr NullCollector::New () +std::shared_ptr NullCollector::New () { - return beast::make_shared (); + return std::make_shared (); } } diff --git a/beast/insight/impl/StatsDCollector.cpp b/beast/insight/impl/StatsDCollector.cpp index 6e958ae604..c92690fa85 100644 --- a/beast/insight/impl/StatsDCollector.cpp +++ b/beast/insight/impl/StatsDCollector.cpp @@ -24,8 +24,10 @@ #include #include #include +#include #include +#include #include #include @@ -57,7 +59,7 @@ class StatsDHookImpl public: StatsDHookImpl ( HandlerType const& handler, - beast::shared_ptr const& impl); + std::shared_ptr const& impl); ~StatsDHookImpl (); @@ -66,7 +68,7 @@ public: private: StatsDHookImpl& operator= (StatsDHookImpl const&); - beast::shared_ptr m_impl; + std::shared_ptr m_impl; HandlerType m_handler; }; @@ -78,7 +80,7 @@ class StatsDCounterImpl { public: StatsDCounterImpl (std::string const& name, - beast::shared_ptr const& impl); + std::shared_ptr const& impl); ~StatsDCounterImpl (); @@ -86,14 +88,13 @@ public: void set_handler (HandlerType const& handler); void flush (); - void do_increment (CounterImpl::value_type amount, - shared_ptr const& ptr); + void do_increment (CounterImpl::value_type amount); void do_process (); private: StatsDCounterImpl& operator= (StatsDCounterImpl const&); - beast::shared_ptr m_impl; + std::shared_ptr m_impl; std::string m_name; CounterImpl::value_type m_value; bool m_dirty; @@ -107,20 +108,19 @@ class StatsDEventImpl { public: StatsDEventImpl (std::string const& name, - beast::shared_ptr const& impl); + std::shared_ptr const& impl); ~StatsDEventImpl (); void notify (EventImpl::value_type value); - void do_notify (EventImpl::value_type value, - shared_ptr const& ptr); + void do_notify (EventImpl::value_type value); void do_process (); private: StatsDEventImpl& operator= (StatsDEventImpl const&); - beast::shared_ptr m_impl; + std::shared_ptr m_impl; std::string m_name; }; @@ -132,7 +132,7 @@ class StatsDGaugeImpl { public: StatsDGaugeImpl (std::string const& name, - beast::shared_ptr const& impl); + std::shared_ptr const& impl); ~StatsDGaugeImpl (); @@ -141,16 +141,14 @@ public: void set_handler (HandlerType const& handler); void flush (); - void do_set (GaugeImpl::value_type value, - shared_ptr const& ptr); - void do_increment (GaugeImpl::difference_type amount, - shared_ptr const& ptr); + void do_set (GaugeImpl::value_type value); + void do_increment (GaugeImpl::difference_type amount); void do_process (); private: StatsDGaugeImpl& operator= (StatsDGaugeImpl const&); - beast::shared_ptr m_impl; + std::shared_ptr m_impl; std::string m_name; GaugeImpl::value_type m_last_value; GaugeImpl::value_type m_value; @@ -166,7 +164,7 @@ class StatsDMeterImpl { public: explicit StatsDMeterImpl (std::string const& name, - beast::shared_ptr const& impl); + std::shared_ptr const& impl); ~StatsDMeterImpl (); @@ -174,14 +172,13 @@ public: void set_handler (HandlerType const& handler); void flush (); - void do_increment (MeterImpl::value_type amount, - shared_ptr const& ptr); + void do_increment (MeterImpl::value_type amount); void do_process (); private: StatsDMeterImpl& operator= (StatsDMeterImpl const&); - beast::shared_ptr m_impl; + std::shared_ptr m_impl; std::string m_name; MeterImpl::value_type m_value; bool m_dirty; @@ -192,7 +189,7 @@ private: class StatsDCollectorImp : public StatsDCollector - , public beast::enable_shared_from_this + , public std::enable_shared_from_this { private: enum @@ -219,7 +216,7 @@ private: State m_state; // Must come last for order of init - beast::thread m_thread; + std::thread m_thread; static boost::asio::ip::udp::endpoint to_endpoint ( IPAddress const &address) @@ -263,31 +260,31 @@ public: Hook make_hook (HookImpl::HandlerType const& handler) { - return Hook (beast::make_shared ( + return Hook (std::make_shared ( handler, shared_from_this ())); } Counter make_counter (std::string const& name) { - return Counter (beast::make_shared ( + return Counter (std::make_shared ( name, shared_from_this ())); } Event make_event (std::string const& name) { - return Event (beast::make_shared ( + return Event (std::make_shared ( name, shared_from_this ())); } Gauge make_gauge (std::string const& name) { - return Gauge (beast::make_shared ( + return Gauge (std::make_shared ( name, shared_from_this ())); } Meter make_meter (std::string const& name) { - return Meter (beast::make_shared ( + return Meter (std::make_shared ( name, shared_from_this ())); } @@ -327,9 +324,9 @@ public: void post_buffer (std::string&& buffer) { - m_io_service.dispatch (boost::bind ( + m_io_service.dispatch (std::bind ( &StatsDCollectorImp::do_post_buffer, this, - boost::move (buffer))); + std::move (buffer))); } void on_send (boost::system::error_code ec, std::size_t) @@ -443,7 +440,7 @@ public: //------------------------------------------------------------------------------ StatsDHookImpl::StatsDHookImpl (HandlerType const& handler, - beast::shared_ptr const& impl) + std::shared_ptr const& impl) : m_impl (impl) , m_handler (handler) { @@ -463,7 +460,7 @@ void StatsDHookImpl::do_process () //------------------------------------------------------------------------------ StatsDCounterImpl::StatsDCounterImpl (std::string const& name, - beast::shared_ptr const& impl) + std::shared_ptr const& impl) : m_impl (impl) , m_name (name) , m_value (0) @@ -479,8 +476,10 @@ StatsDCounterImpl::~StatsDCounterImpl () void StatsDCounterImpl::increment (CounterImpl::value_type amount) { - m_impl->get_io_service().dispatch (boost::bind ( - &StatsDCounterImpl::do_increment, this, amount, shared_from_this())); + m_impl->get_io_service().dispatch (std::bind ( + &StatsDCounterImpl::do_increment, + std::static_pointer_cast ( + shared_from_this ()), amount)); } void StatsDCounterImpl::set_handler (HandlerType const& handler) @@ -504,8 +503,7 @@ void StatsDCounterImpl::flush () } } -void StatsDCounterImpl::do_increment (CounterImpl::value_type amount, - shared_ptr const&) +void StatsDCounterImpl::do_increment (CounterImpl::value_type amount) { m_value += amount; m_dirty = true; @@ -521,7 +519,7 @@ void StatsDCounterImpl::do_process () //------------------------------------------------------------------------------ StatsDEventImpl::StatsDEventImpl (std::string const& name, - beast::shared_ptr const& impl) + std::shared_ptr const& impl) : m_impl (impl) , m_name (name) { @@ -533,12 +531,13 @@ StatsDEventImpl::~StatsDEventImpl () void StatsDEventImpl::notify (EventImpl::value_type value) { - m_impl->get_io_service().dispatch (boost::bind ( - &StatsDEventImpl::do_notify, this, value, shared_from_this())); + m_impl->get_io_service().dispatch (std::bind ( + &StatsDEventImpl::do_notify, + std::static_pointer_cast ( + shared_from_this ()), value)); } -void StatsDEventImpl::do_notify (EventImpl::value_type value, - shared_ptr const&) +void StatsDEventImpl::do_notify (EventImpl::value_type value) { std::stringstream ss; ss << @@ -552,7 +551,7 @@ void StatsDEventImpl::do_notify (EventImpl::value_type value, //------------------------------------------------------------------------------ StatsDGaugeImpl::StatsDGaugeImpl (std::string const& name, - beast::shared_ptr const& impl) + std::shared_ptr const& impl) : m_impl (impl) , m_name (name) , m_last_value (0) @@ -569,14 +568,18 @@ StatsDGaugeImpl::~StatsDGaugeImpl () void StatsDGaugeImpl::set (GaugeImpl::value_type value) { - m_impl->get_io_service().dispatch (boost::bind ( - &StatsDGaugeImpl::do_set, this, value, shared_from_this ())); + m_impl->get_io_service().dispatch (std::bind ( + &StatsDGaugeImpl::do_set, + std::static_pointer_cast ( + shared_from_this ()), value)); } void StatsDGaugeImpl::increment (GaugeImpl::difference_type amount) { - m_impl->get_io_service().dispatch (boost::bind ( - &StatsDGaugeImpl::do_increment, this, amount, shared_from_this())); + m_impl->get_io_service().dispatch (std::bind ( + &StatsDGaugeImpl::do_increment, + std::static_pointer_cast ( + shared_from_this ()), amount)); } void StatsDGaugeImpl::set_handler (HandlerType const& handler) @@ -599,8 +602,7 @@ void StatsDGaugeImpl::flush () } } -void StatsDGaugeImpl::do_set (GaugeImpl::value_type value, - shared_ptr const&) +void StatsDGaugeImpl::do_set (GaugeImpl::value_type value) { m_value = value; @@ -611,8 +613,7 @@ void StatsDGaugeImpl::do_set (GaugeImpl::value_type value, } } -void StatsDGaugeImpl::do_increment (GaugeImpl::difference_type amount, - shared_ptr const& ptr) +void StatsDGaugeImpl::do_increment (GaugeImpl::difference_type amount) { GaugeImpl::value_type value (m_value); @@ -631,7 +632,7 @@ void StatsDGaugeImpl::do_increment (GaugeImpl::difference_type amount, : std::abs (amount); } - do_set (value, ptr); + do_set (value); } void StatsDGaugeImpl::do_process () @@ -644,7 +645,7 @@ void StatsDGaugeImpl::do_process () //------------------------------------------------------------------------------ StatsDMeterImpl::StatsDMeterImpl (std::string const& name, - beast::shared_ptr const& impl) + std::shared_ptr const& impl) : m_impl (impl) , m_name (name) , m_value (0) @@ -660,8 +661,10 @@ StatsDMeterImpl::~StatsDMeterImpl () void StatsDMeterImpl::increment (MeterImpl::value_type amount) { - m_impl->get_io_service().dispatch (boost::bind ( - &StatsDMeterImpl::do_increment, this, amount, shared_from_this())); + m_impl->get_io_service().dispatch (std::bind ( + &StatsDMeterImpl::do_increment, + std::static_pointer_cast ( + shared_from_this ()), amount)); } void StatsDMeterImpl::set_handler (HandlerType const& handler) @@ -685,8 +688,7 @@ void StatsDMeterImpl::flush () } } -void StatsDMeterImpl::do_increment (MeterImpl::value_type amount, - shared_ptr const&) +void StatsDMeterImpl::do_increment (MeterImpl::value_type amount) { m_value += amount; m_dirty = true; @@ -703,10 +705,10 @@ void StatsDMeterImpl::do_process () //------------------------------------------------------------------------------ -shared_ptr StatsDCollector::New ( +std::shared_ptr StatsDCollector::New ( IPAddress const& address, std::string const& prefix, Journal journal) { - return beast::make_shared ( + return std::make_shared ( address, prefix, journal); } diff --git a/beast/intrusive/ForwardList.h b/beast/intrusive/ForwardList.h deleted file mode 100644 index 86264d0d2f..0000000000 --- a/beast/intrusive/ForwardList.h +++ /dev/null @@ -1,448 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_INTRUSIVE_FORWARDLIST_H_INCLUDED -#define BEAST_INTRUSIVE_FORWARDLIST_H_INCLUDED - -#include "../Config.h" - -#include "PointerTraits.h" - -#include "../MPL.h" - -#include - -// Ideas based on boost - -namespace beast { -namespace intrusive { - -//------------------------------------------------------------------------------ - -namespace detail { - -// Holds the size field -struct SizeHolder -{ -public: - typedef std::size_t size_type; - - inline size_type size () const noexcept - { - return m_size; - } - - inline void set (size_type new_size) noexcept - { - m_size = new_size; - } - - inline void increment () noexcept - { - ++m_size; - } - - inline void decrement () noexcept - { - --m_size; - } - -private: - size_type m_size; -}; - -} - -//------------------------------------------------------------------------------ - -template -struct ForwardListNode -{ - typedef typename PointerTraits ::template rebind_pointer ::type node_ptr; - - node_ptr next; -}; - -//------------------------------------------------------------------------------ - -// Provides value_traits for when T derives from Node -template -struct DerivedValueTraits -{ - typedef NodeTraits node_traits; - typedef T value_type; - typedef typename node_traits::node node; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::const_node_ptr const_node_ptr; - typedef typename mpl::PointerToOther ::type pointer; - typedef typename mpl::PointerToOther ::type const_pointer; - typedef typename PointerTraits ::reference reference; - typedef typename PointerTraits ::reference const_reference; - - static node_ptr to_node_ptr (reference value) - { - return node_ptr (&value); - } - - static const_node_ptr to_node_ptr (const_reference value) - { - return node_ptr (&value); - } - - static pointer to_value_ptr (node_ptr const& n) - { - return pointer (&static_cast (*n)); - } - - static const_pointer to_value_ptr (const_node_ptr const &n) - { - return const_pointer (&static_cast (*n)); - } -}; - -//------------------------------------------------------------------------------ - -template -struct ForwardListNodeTraits -{ - typedef ForwardListNode node; - - typedef typename PointerTraits :: - template rebind_pointer node_ptr; - - typedef typename PointerTraits :: - template rebind_pointer const_node_ptr; - - static node_ptr get_next (const_node_ptr const& n) - { - return n->m_next; - } - - static node_ptr get_next (node_ptr const& n) - { - return n->m_next; - } - - static void set_next (node_ptr const& n, node_ptr const& next) - { - n->m_next = next; - } -}; - -//------------------------------------------------------------------------------ - -template -class ForwardListIterator - : public std::iterator < - std::forward_iterator_tag, - typename Container::value_type, - typename Container::difference_type, - typename mpl::IfCond ::type, - typename mpl::IfCond ::type> -{ -protected: - typedef typename Container::value_traits value_traits; - typedef typename Container::node_traits node_traits; - typedef typename node_traits::node node; - typedef typename node_traits::node_ptr node_ptr; - typedef typename PointerTraits :: - template rebind_pointer ::type void_pointer; - -public: - typedef typename Container::value_type value_type; - typedef typename mpl::IfCond ::type pointer; - typedef typename mpl::IfCond ::type reference; - - ForwardListIterator () - : m_node () - { - } - - explicit ForwardListIterator (ForwardListIterator const& other) - : m_node (other.pointed_node ()) - { - } - - node_ptr const& pointed_node () const noexcept - { - return m_node; - } - - ForwardListIterator& operator= (node_ptr const& node) - { - m_node = node; - return static_cast (*this); - } - - ForwardListIterator& operator++ () - { - m_node = node_traits::get_next (m_node); - return static_cast (*this); - } - - ForwardListIterator operator++ (int) - { - ForwardListIterator result (*this); - m_node = node_traits::get_next (m_node); - return result; - } - - friend bool operator== (ForwardListIterator const& lhs, - ForwardListIterator const& rhs) - { - return lhs.m_node == rhs.m_node; - } - - friend bool operator!= (ForwardListIterator const& lhs, - ForwardListIterator const& rhs) - { - return ! (lhs == rhs); - } - - reference operator* () const - { - return *this->operator-> (); - } - - pointer operator-> () const - { - return value_traits::to_value_ptr (m_node); - } - -private: - node_ptr m_node; -}; - -//------------------------------------------------------------------------------ - -template -class ForwardListAlgorithms -{ -public: - typedef typename NodeTraits::node node; - typedef typename NodeTraits::node_ptr node_ptr; - typedef typename NodeTraits::const_node_ptr const_node_ptr; - typedef NodeTraits node_traits; - - static void init (node_ptr const& n) - { - NodeTraits::set_next (n, node_ptr()); - } - - static bool unique (const_node_ptr const& this_node) - { - node_ptr next = NodeTraits::get_next (this_node); - return !next || next == this_node; - } - - static void link_after (node_ptr const& prev_node, node_ptr const& this_node) - { - NodeTraits::set_next (this_node, NodeTraits::get_next (prev_node)); - NodeTraits::set_next (prev_node, this_node); - } - - static void unlink_after (node_ptr const& prev_node) - { - const_node_ptr this_node (NodeTraits::get_next (prev_node)); - NodeTraits::set_next (prev_node, NodeTraits::get_next (this_node)); - } -}; - -//------------------------------------------------------------------------------ - -/** Singly-linked intrusive list. */ -template -class ForwardList -{ -public: - typedef DerivedValueTraits > - value_traits; - typedef typename value_traits::pointer pointer; - typedef typename value_traits::const_pointer const_pointer; - typedef typename PointerTraits ::element_type value_type; - typedef typename PointerTraits ::reference reference; - typedef typename PointerTraits ::const_reference const_reference; - typedef typename PointerTraits ::difference_type difference_type; - typedef std::size_t size_type; - typedef ForwardListIterator iterator; - typedef ForwardListIterator const_iterator; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::node node; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::const_node_ptr const_node_ptr; - typedef ForwardListAlgorithms node_algorithms; - - typedef node Node; - -private: - typedef detail::SizeHolder size_traits; - - void default_construct () - { - get_size_traits ().set (size_type (0)); - node_algorithms::init (this->get_root_node ()); - } - - node_ptr get_end_node () - { - return node_ptr (); - } - - const_node_ptr get_end_node () const - { - return const_node_ptr (); - } - - node_ptr get_root_node () - { - return PointerTraits ::pointer_to (m_root); - } - - const_node_ptr get_root_node () const - { - return PointerTraits ::pointer_to (m_root); - } - - size_traits& get_size_traits () noexcept - { - return m_size; - } - - size_traits const& get_size_traits () const noexcept - { - return m_size; - } - - static node_ptr uncast (const_node_ptr const& ptr) - { - return PointerTraits ::const_cast_from (ptr); - } - -public: - ForwardList () - { - default_construct (); - } - - void clear () - { - default_construct (); - } - - void push_front (reference value) - { - node_ptr this_node (value_traits::to_node_ptr (value)); - node_algorithms::link_after (this->get_root_node (), this_node); - this->get_size_traits ().increment (); - } - - void pop_front () - { - //node_ptr this_node (node_traits::get_next (this->get_root ())); - node_algorithms::unlink_after (this->get_root_node ()); - this->get_size_traits ().decrement (); - } - - reference front () - { - return *value_traits::to_value_ptr (node_traits::get_next (this->get_root_node ())); - } - - const_reference front () const - { - return *value_traits::to_value_ptr (uncat (node_traits::get_next (this->get_root_node ()))); - } - - iterator begin () - { - return iterator (node_traits::get_next (this->get_root_node (), this)); - } - - const_iterator begin () const - { - return const_iterator (node_traits::get_next (this->get_root_node (), this)); - } - - const_iterator cbegin () const - { - return this->begin (); - } - - iterator end () - { - return iterator (this->get_end_node (), this); - } - - const_iterator end () const - { - return const_iterator (this->get_end_node (), this); - } - - const_iterator cend () const - { - return this->end (); - } - - iterator before_begin () - { - return iterator (this->get_root_node (), this); - } - - const_iterator before_begin () const - { - return const_iterator (this->get_root_node (), this); - } - - const_iterator cbefore_begin () const - { - return before_begin (); - } - - bool empty () const - { - return node_algorithms::unique (this->get_root_node ()); - } - - iterator iterator_to (reference value) - { - return iterator (value_traits::to_node_ptr (value), this); - } - - const_iterator iterator_to (const_reference value) const - { - return const_iterator (value_traits::to_node_ptr (const_cast (value)), this); - } - -private: - node m_root; - size_traits m_size; -}; - -} -} - -#endif diff --git a/beast/intrusive/IntrusiveArray.h b/beast/intrusive/IntrusiveArray.h deleted file mode 100644 index 53fbe0b057..0000000000 --- a/beast/intrusive/IntrusiveArray.h +++ /dev/null @@ -1,187 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_INTRUSIVE_INTRUSIVEARRAY_H_INCLUDED -#define BEAST_INTRUSIVE_INTRUSIVEARRAY_H_INCLUDED - -#include "../Config.h" - -#include -#include -#include -#include - -namespace beast { - -/** A run-time fixed size array that references outside storage. - The interface tries to follow std::vector as closely as possible within - the limitations of a fixed size and unowned storage. -*/ -template -class IntrusiveArray -{ -private: - T* m_begin; - T* m_end; - -public: - typedef T value_type; - typedef T* iterator; - typedef T const* const_iterator; - typedef T& reference; - typedef T const& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - // Calling methods on a default constructed - // array results in undefined behavior! - // - IntrusiveArray () - : m_begin (nullptr), m_end (nullptr) - { } - IntrusiveArray (T* begin, T* end) - : m_begin (begin), m_end (end) - { } - IntrusiveArray (IntrusiveArray const& other) - : m_begin (other.m_begin), m_end (other.m_end) - { } - IntrusiveArray (std::vector const& v) - : m_begin (&v.front()), m_end (&v.back()+1) - { } - IntrusiveArray (std::vector & v) - : m_begin (&v.front()), m_end (&v.back()+1) - { } - IntrusiveArray& operator= (IntrusiveArray const& other) - { - m_begin = other.m_begin; - m_end = other.m_end; - return *this; - } - - // iterators - iterator begin() { return m_begin; } - const_iterator begin() const { return m_begin; } - const_iterator cbegin() const { return m_begin; } - iterator end() { return m_end; } - const_iterator end() const { return m_end; } - const_iterator cend() const { return m_end; } - - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } - const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } - const_reverse_iterator crend() const { return const_reverse_iterator(begin()); } - - reference operator[](size_type i) - { - bassert (i < size()); - return m_begin[i]; - } - - const_reference operator[](size_type i) const - { - bassert (i < size()); - return m_begin[i]; - } - - reference at(size_type i) { rangecheck(i); return m_begin[i]; } - const_reference at(size_type i) const { rangecheck(i); return m_begin[i]; } - - reference front() { return m_begin[0]; } - reference back() { return m_end[-1]; } - const_reference front () const { return m_begin; } - const_reference back() const { return m_end[-1]; } - - size_type size() const { return std::distance (m_begin, m_end); } - bool empty() const { return m_begin == m_end; } - - T const* data() const { return m_begin; } - T* data() { return m_begin; } - T* c_array() { return m_begin; } - - void assign (T const& value) { fill (value); } - - void fill (T const& value) - { - std::fill_n (begin(), size(), value); - } - - void clear () - { - fill (T ()); - } - - void rangecheck (size_type i) - { - if (i >= size()) - throw std::out_of_range ("IntrusiveArray<>: index out of range"); - } -}; - -//------------------------------------------------------------------------------ - -template -bool operator== (IntrusiveArray const& lhs, IntrusiveArray const& rhs) -{ - if ((lhs.begin() == rhs.begin()) && (lhs.end() == rhs.end())) - return true; - if (lhs.size() != rhs.size()) - return false; - return std::equal (lhs.begin(), lhs.end(), rhs.begin()); -} - -template -bool operator!= (IntrusiveArray const& lhs, IntrusiveArray const& rhs) -{ - return !(lhs==rhs); -} - -template -bool operator< (IntrusiveArray const& lhs, IntrusiveArray const& rhs) -{ - if ((lhs.begin() == rhs.begin()) && (lhs.end() == rhs.end())) - return false; - return std::lexicographical_compare (lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); -} - -template -bool operator> (IntrusiveArray const& lhs, IntrusiveArray const& rhs) -{ - return rhs -bool operator<= (IntrusiveArray const& lhs, IntrusiveArray const& rhs) -{ - return !(rhs -bool operator>= (IntrusiveArray const& lhs, IntrusiveArray const& rhs) -{ - return !(lhs +#include namespace beast { template class List; -namespace detail +namespace detail { + +/** Copy `const` attribute from T to U if present. */ +/** @{ */ +template +struct CopyConst { + typedef typename std::remove_const ::type type; +}; + +template +struct CopyConst +{ + typedef typename std::remove_const ::type const type; +}; +/** @} */ // This is the intrusive portion of the doubly linked list. // One derivation per list that the object may appear on @@ -62,11 +74,11 @@ class ListIterator : public std::iterator < std::bidirectional_iterator_tag, std::size_t> { public: - typedef typename mpl::CopyConst::type - value_type; - typedef value_type* pointer; - typedef value_type& reference; - typedef std::size_t size_type; + typedef typename detail::CopyConst < + N, typename N::value_type>::type value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::size_t size_type; ListIterator (N* node = nullptr) noexcept : m_node (node) diff --git a/beast/intrusive/LockFreeStack.h b/beast/intrusive/LockFreeStack.h index 7de727fd94..c4452bec0e 100644 --- a/beast/intrusive/LockFreeStack.h +++ b/beast/intrusive/LockFreeStack.h @@ -20,11 +20,12 @@ #ifndef BEAST_INTRUSIVE_LOCKFREESTACK_H_INCLUDED #define BEAST_INTRUSIVE_LOCKFREESTACK_H_INCLUDED -#include -#include "../mpl/IfCond.h" #include "../Atomic.h" #include "../Uncopyable.h" +#include +#include + namespace beast { //------------------------------------------------------------------------------ @@ -35,23 +36,24 @@ class LockFreeStackIterator std::forward_iterator_tag, typename Container::value_type, typename Container::difference_type, - typename mpl::IfCond ::type, - typename mpl::IfCond ::type> { protected: typedef typename Container::Node Node; - typedef typename mpl::IfCond ::type NodePtr; + typedef typename std::conditional < + IsConst, Node const*, Node*>::type NodePtr; public: typedef typename Container::value_type value_type; - typedef typename mpl::IfCond ::type pointer; - typedef typename mpl::IfCond ::type reference; diff --git a/beast/intrusive/PointerTraits.h b/beast/intrusive/PointerTraits.h deleted file mode 100644 index ccba95f91e..0000000000 --- a/beast/intrusive/PointerTraits.h +++ /dev/null @@ -1,89 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_INTRUSIVE_POINTERTRAITS_H_INCLUDED -#define BEAST_INTRUSIVE_POINTERTRAITS_H_INCLUDED - -#include - -namespace beast { -namespace intrusive { - -// an unspecialized PointerTraits is ill-defined -template -struct PointerTraits; - -// specializations to remove cv-qualifiers -template -struct PointerTraits : PointerTraits { }; -template -struct PointerTraits : PointerTraits { }; -template
: PointerTraits
{ }; -template -struct PointerTraits : PointerTraits { }; -template
{ }; -template