New utility classes, containers, C++14 compatibility, and fixes:

* Add std::equal_to <void> (since C++14)
* Add heterogeneous std::equal (since C++14)
* Add maybe_const
* Add empty_base_optimization
* Add is_constructible specialization for pair, tuple
* Add aged associative containers:
  - aged_set, aged_map, aged_multiset, aged_multimap
  - aged_unordered_set, aged_unordered_map,
  - aged_unordered_multiset, aged_unordered_multimap
* Fix auto keyword pass by reference
* Fix basic_seconds_clock warning and project file
This commit is contained in:
Vinnie Falco
2014-02-16 19:43:16 -08:00
parent c48b9244f2
commit 78e1995365
26 changed files with 7070 additions and 11 deletions

View File

@@ -8,7 +8,7 @@
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>BEAST_COMPILING_STATIC_LIBARARY=1;_CRTDBG_MAP_ALLOC;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>BEAST_COMPILING_STATIC_LIBARARY=1;_CRTDBG_MAP_ALLOC;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>$(RepoDir)\config;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

View File

@@ -116,6 +116,20 @@
<ClInclude Include="..\..\beast\config\SelectPlatformConfig.h" />
<ClInclude Include="..\..\beast\config\SelectStdlibConfig.h" />
<ClInclude Include="..\..\beast\config\StandardConfig.h" />
<ClInclude Include="..\..\beast\container\aged_container_utility.h" />
<ClInclude Include="..\..\beast\container\aged_container.h" />
<ClInclude Include="..\..\beast\container\aged_map.h" />
<ClInclude Include="..\..\beast\container\aged_multimap.h" />
<ClInclude Include="..\..\beast\container\aged_multiset.h" />
<ClInclude Include="..\..\beast\container\aged_set.h" />
<ClInclude Include="..\..\beast\container\aged_unordered_map.h" />
<ClInclude Include="..\..\beast\container\aged_unordered_multimap.h" />
<ClInclude Include="..\..\beast\container\aged_unordered_multiset.h" />
<ClInclude Include="..\..\beast\container\aged_unordered_set.h" />
<ClInclude Include="..\..\beast\container\detail\aged_associative_container.h" />
<ClInclude Include="..\..\beast\container\detail\aged_ordered_container.h" />
<ClInclude Include="..\..\beast\container\detail\aged_container_iterator.h" />
<ClInclude Include="..\..\beast\container\detail\aged_unordered_container.h" />
<ClInclude Include="..\..\beast\Crypto.h" />
<ClInclude Include="..\..\beast\crypto\BinaryEncoding.h" />
<ClInclude Include="..\..\beast\crypto\impl\sha2\sha2.h" />
@@ -125,6 +139,8 @@
<ClInclude Include="..\..\beast\crypto\UnsignedIntegerCalc.h" />
<ClInclude Include="..\..\beast\CStdInt.h" />
<ClInclude Include="..\..\beast\cyclic_iterator.h" />
<ClInclude Include="..\..\beast\equal.h" />
<ClInclude Include="..\..\beast\equal_to.h" />
<ClInclude Include="..\..\beast\FixedArray.h" />
<ClInclude Include="..\..\beast\HeapBlock.h" />
<ClInclude Include="..\..\beast\HTTP.h" />
@@ -152,6 +168,7 @@
<ClInclude Include="..\..\beast\Intrusive.h" />
<ClInclude Include="..\..\beast\intrusive\List.h" />
<ClInclude Include="..\..\beast\intrusive\LockFreeStack.h" />
<ClInclude Include="..\..\beast\is_constructible.h" />
<ClInclude Include="..\..\beast\make_unique.h" />
<ClInclude Include="..\..\beast\Memory.h" />
<ClInclude Include="..\..\beast\MPL.h" />
@@ -205,11 +222,13 @@
<ClInclude Include="..\..\beast\type_traits\IntegralConstant.h" />
<ClInclude Include="..\..\beast\type_traits\IsIntegral.h" />
<ClInclude Include="..\..\beast\type_traits\IsSigned.h" />
<ClInclude Include="..\..\beast\type_traits\maybe_const.h" />
<ClInclude Include="..\..\beast\type_traits\RemoveSigned.h" />
<ClInclude Include="..\..\beast\Uncopyable.h" />
<ClInclude Include="..\..\beast\Utility.h" />
<ClInclude Include="..\..\beast\utility\BaseFromMember.h" />
<ClInclude Include="..\..\beast\utility\Debug.h" />
<ClInclude Include="..\..\beast\utility\empty_base_optimization.h" />
<ClInclude Include="..\..\beast\utility\EnableIf.h" />
<ClInclude Include="..\..\beast\utility\Error.h" />
<ClInclude Include="..\..\beast\utility\hash_pair.h" />
@@ -416,6 +435,12 @@
</ClCompile>
<ClCompile Include="..\..\beast\boost\Boost.cpp" />
<ClCompile Include="..\..\beast\chrono\Chrono.cpp" />
<ClCompile Include="..\..\beast\chrono\impl\basic_seconds_clock.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\beast\chrono\impl\chrono_io.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -440,6 +465,13 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\beast\container\Container.cpp" />
<ClCompile Include="..\..\beast\container\impl\aged_associative_container.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\beast\crypto\Crypto.cpp" />
<ClCompile Include="..\..\beast\crypto\impl\BinaryEncoding.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>

View File

@@ -195,9 +195,6 @@
<Filter Include="beast">
<UniqueIdentifier>{92d1bb42-289a-4444-85c7-cb87540f2fff}</UniqueIdentifier>
</Filter>
<Filter Include="beast\intrusive">
<UniqueIdentifier>{8832eb52-53f9-4850-8dc9-1d579a386a0e}</UniqueIdentifier>
</Filter>
<Filter Include="beast\mpl">
<UniqueIdentifier>{5904368f-a0f2-4d26-a031-8cbe4448dc3f}</UniqueIdentifier>
</Filter>
@@ -297,6 +294,18 @@
<Filter Include="beast\net\detail">
<UniqueIdentifier>{43cc0f2a-9905-4081-8104-48d2c4be9e7e}</UniqueIdentifier>
</Filter>
<Filter Include="beast\container">
<UniqueIdentifier>{48c7ee12-704c-42cb-99ea-9a486bb4b57e}</UniqueIdentifier>
</Filter>
<Filter Include="beast\container\impl">
<UniqueIdentifier>{e30eda19-95b4-4831-b86a-ee5fae88abd2}</UniqueIdentifier>
</Filter>
<Filter Include="beast\container\detail">
<UniqueIdentifier>{a4dca8cc-7d1f-4353-b7e1-15eab33e8bd4}</UniqueIdentifier>
</Filter>
<Filter Include="beast\intrusive">
<UniqueIdentifier>{8832eb52-53f9-4850-8dc9-1d579a386a0e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\modules\beast_core\beast_core.h">
@@ -1269,6 +1278,66 @@
<ClInclude Include="..\..\beast\chrono\ScopedTimeInterval.h">
<Filter>beast\chrono</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\equal_to.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\equal.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\type_traits\maybe_const.h">
<Filter>beast\type_traits</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\utility\empty_base_optimization.h">
<Filter>beast\utility</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\detail\aged_associative_container.h">
<Filter>beast\container\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\detail\aged_container_iterator.h">
<Filter>beast\container\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_map.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_multimap.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_multiset.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_set.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_unordered_map.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_unordered_multimap.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_unordered_multiset.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_unordered_set.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\detail\aged_ordered_container.h">
<Filter>beast\container\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\detail\aged_unordered_container.h">
<Filter>beast\container\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\detail\aged_associative_container.h">
<Filter>beast\container\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\is_constructible.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_container_utility.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\container\aged_container.h">
<Filter>beast\container</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\modules\beast_core\containers\DynamicObject.cpp">
@@ -1847,6 +1916,15 @@
<ClCompile Include="..\..\beast\chrono\Chrono.cpp">
<Filter>beast\chrono</Filter>
</ClCompile>
<ClCompile Include="..\..\beast\chrono\impl\basic_seconds_clock.cpp">
<Filter>beast\chrono\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\beast\container\Container.cpp">
<Filter>beast\container</Filter>
</ClCompile>
<ClCompile Include="..\..\beast\container\impl\aged_associative_container.cpp">
<Filter>beast\container\impl</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\TODO.txt">

View File

@@ -31,8 +31,7 @@ public:
{
beginTestCase ("now");
auto const now (basic_seconds_clock <
std::chrono::steady_clock>::now ());
basic_seconds_clock <std::chrono::steady_clock>::now ();
pass ();
}

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include "BeastConfig.h"
#include "impl/aged_associative_container.cpp"

View File

@@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_CONTAINER_H_INCLUDED
#define BEAST_CONTAINER_AGED_CONTAINER_H_INCLUDED
#include <type_traits>
namespace beast {
template <class T>
struct is_aged_container
: std::false_type
{
};
}
#endif

View File

@@ -0,0 +1,51 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_CONTAINER_UTILITY_H_INCLUDED
#define BEAST_CONTAINER_AGED_CONTAINER_UTILITY_H_INCLUDED
#include "aged_container.h"
#include <type_traits>
namespace beast {
/** Expire aged container items past the specified age. */
template <class AgedContainer, class Rep, class Period>
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);
auto const expired (c.clock().now() - age);
for (auto iter (c.chronological.cbegin());
iter != c.chronological.cend() &&
iter.when() <= expired;)
{
iter = c.erase (iter);
++n;
}
return n;
}
}
#endif

View File

@@ -0,0 +1,43 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_MAP_H_INCLUDED
#define BEAST_CONTAINER_AGED_MAP_H_INCLUDED
#include "detail/aged_ordered_container.h"
#include <chrono>
#include <functional>
#include <memory>
namespace beast {
template <
class Key,
class T,
class Duration = std::chrono::seconds,
class Compare = std::less <Key>,
class Allocator = std::allocator <std::pair <Key const, T>>
>
using aged_map = detail::aged_ordered_container <
false, true, Key, T, Duration, Compare, Allocator>;
}
#endif

View File

@@ -0,0 +1,43 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_MULTIMAP_H_INCLUDED
#define BEAST_CONTAINER_AGED_MULTIMAP_H_INCLUDED
#include "detail/aged_ordered_container.h"
#include <chrono>
#include <functional>
#include <memory>
namespace beast {
template <
class Key,
class T,
class Duration = std::chrono::seconds,
class Compare = std::less <Key>,
class Allocator = std::allocator <std::pair <Key const, T>>
>
using aged_multimap = detail::aged_ordered_container <
true, true, Key, T, Duration, Compare, Allocator>;
}
#endif

View File

@@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_MULTISET_H_INCLUDED
#define BEAST_CONTAINER_AGED_MULTISET_H_INCLUDED
#include "detail/aged_ordered_container.h"
#include <chrono>
#include <functional>
#include <memory>
namespace beast {
template <
class Key,
class Duration = std::chrono::seconds,
class Compare = std::less <Key>,
class Allocator = std::allocator <Key>
>
using aged_multiset = detail::aged_ordered_container <
true, false, Key, void, Duration, Compare, Allocator>;
}
#endif

View File

@@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_SET_H_INCLUDED
#define BEAST_CONTAINER_AGED_SET_H_INCLUDED
#include "detail/aged_ordered_container.h"
#include <chrono>
#include <functional>
#include <memory>
namespace beast {
template <
class Key,
class Duration = std::chrono::seconds,
class Compare = std::less <Key>,
class Allocator = std::allocator <Key>
>
using aged_set = detail::aged_ordered_container <
false, false, Key, void, Duration, Compare, Allocator>;
}
#endif

View File

@@ -0,0 +1,44 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_UNORDERED_MAP_H_INCLUDED
#define BEAST_CONTAINER_AGED_UNORDERED_MAP_H_INCLUDED
#include "detail/aged_unordered_container.h"
#include <chrono>
#include <functional>
#include <memory>
namespace beast {
template <
class Key,
class T,
class Duration = std::chrono::seconds,
class Hash = std::hash <Key>,
class KeyEqual = std::equal_to <Key>,
class Allocator = std::allocator <std::pair <Key const, T>>
>
using aged_unordered_map = detail::aged_unordered_container <
false, true, Key, T, Duration, Hash, KeyEqual, Allocator>;
}
#endif

View File

@@ -0,0 +1,44 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_UNORDERED_MULTIMAP_H_INCLUDED
#define BEAST_CONTAINER_AGED_UNORDERED_MULTIMAP_H_INCLUDED
#include "detail/aged_unordered_container.h"
#include <chrono>
#include <functional>
#include <memory>
namespace beast {
template <
class Key,
class T,
class Duration = std::chrono::seconds,
class Hash = std::hash <Key>,
class KeyEqual = std::equal_to <Key>,
class Allocator = std::allocator <std::pair <Key const, T>>
>
using aged_unordered_multimap = detail::aged_unordered_container <
true, true, Key, T, Duration, Hash, KeyEqual, Allocator>;
}
#endif

View File

@@ -0,0 +1,43 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_UNORDERED_MULTISET_H_INCLUDED
#define BEAST_CONTAINER_AGED_UNORDERED_MULTISET_H_INCLUDED
#include "detail/aged_unordered_container.h"
#include <chrono>
#include <functional>
#include <memory>
namespace beast {
template <
class Key,
class Duration = std::chrono::seconds,
class Hash = std::hash <Key>,
class KeyEqual = std::equal_to <Key>,
class Allocator = std::allocator <Key>
>
using aged_unordered_multiset = detail::aged_unordered_container <
true, false, Key, void, Duration, Hash, KeyEqual, Allocator>;
}
#endif

View File

@@ -0,0 +1,43 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_UNORDERED_SET_H_INCLUDED
#define BEAST_CONTAINER_AGED_UNORDERED_SET_H_INCLUDED
#include "detail/aged_unordered_container.h"
#include <chrono>
#include <functional>
#include <memory>
namespace beast {
template <
class Key,
class Duration = std::chrono::seconds,
class Hash = std::hash <Key>,
class KeyEqual = std::equal_to <Key>,
class Allocator = std::allocator <Key>
>
using aged_unordered_set = detail::aged_unordered_container <
false, false, Key, void, Duration, Hash, KeyEqual, Allocator>;
}
#endif

View File

@@ -0,0 +1,54 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_ASSOCIATIVE_CONTAINER_H_INCLUDED
#define BEAST_CONTAINER_AGED_ASSOCIATIVE_CONTAINER_H_INCLUDED
#include <type_traits>
namespace beast {
namespace detail {
// Extracts the key portion of value
template <bool maybe_map>
struct aged_associative_container_extract_t
{
template <class Value>
decltype (Value::first) const&
operator() (Value const& value) const
{
return value.first;
}
};
template <>
struct aged_associative_container_extract_t <false>
{
template <class Value>
Value const&
operator() (Value const& value) const
{
return value;
}
};
}
}
#endif

View File

@@ -0,0 +1,156 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_CONTAINER_AGED_CONTAINER_ITERATOR_H_INCLUDED
#define BEAST_CONTAINER_AGED_CONTAINER_ITERATOR_H_INCLUDED
#include <iterator>
#include <type_traits>
namespace beast {
template <bool, bool, class, class, class, class, class>
class aged_ordered_container;
namespace detail {
// Idea for Base template argument to prevent having to repeat
// the base class declaration comes from newbiz on ##c++/Freenode
//
// If Iterator is SCARY then this iterator will be as well.
template <
bool is_const,
class Iterator,
class Base =
std::iterator <
typename std::iterator_traits <Iterator>::iterator_category,
typename std::conditional <is_const,
typename Iterator::value_type::stashed::value_type const,
typename Iterator::value_type::stashed::value_type>::type,
typename std::iterator_traits <Iterator>::difference_type>
>
class aged_container_iterator
: public Base
{
public:
typedef typename Iterator::value_type::stashed::time_point time_point;
aged_container_iterator ()
{
}
template <class OtherIterator, class OtherBase>
aged_container_iterator (aged_container_iterator <
false, OtherIterator, OtherBase> const& other)
: m_iter (other.m_iter)
{
}
template <bool other_is_const, class OtherIterator, class OtherBase>
aged_container_iterator& operator= (aged_container_iterator <
other_is_const, OtherIterator, OtherBase> const& other)
{
m_iter = other.m_iter;
return *this;
}
template <bool other_is_const, class OtherIterator, class OtherBase>
bool operator== (aged_container_iterator <
other_is_const, OtherIterator, OtherBase> const& other) const
{
return m_iter == other.m_iter;
}
template <bool other_is_const, class OtherIterator, class OtherBase>
bool operator!= (aged_container_iterator <
other_is_const, OtherIterator, OtherBase> const& other) const
{
return m_iter != other.m_iter;
}
aged_container_iterator& operator++ ()
{
++m_iter;
return *this;
}
aged_container_iterator operator++ (int)
{
aged_container_iterator const prev (*this);
++m_iter;
return prev;
}
aged_container_iterator& operator-- ()
{
--m_iter;
return *this;
}
aged_container_iterator operator-- (int)
{
aged_container_iterator const prev (*this);
--m_iter;
return prev;
}
typename Base::reference operator* () const
{
return m_iter->value;
}
typename Base::pointer operator-> () const
{
return &m_iter->value;
}
time_point const& when () const
{
return m_iter->when;
}
private:
template <bool, bool, class, class, class, class, class>
friend class aged_ordered_container;
template <bool, bool, class, class, class, class, class, class>
friend class aged_unordered_container;
template <bool, class, class>
friend class aged_container_iterator;
template <class OtherIterator>
aged_container_iterator (OtherIterator const& iter)
: m_iter (iter)
{
}
Iterator const& iterator() const
{
return m_iter;
}
Iterator m_iter;
};
}
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

90
beast/equal.h Normal file
View File

@@ -0,0 +1,90 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_EQUAL_H_INCLUDED
#define BEAST_EQUAL_H_INCLUDED
#include "equal_to.h"
#include <functional>
#include <type_traits>
namespace std {
namespace detail {
template <class Pred, class FwdIt1, class FwdIt2>
bool equal (FwdIt1 first1, FwdIt1 last1,
FwdIt2 first2, FwdIt2 last2, Pred pred,
std::input_iterator_tag, std::input_iterator_tag)
{
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
if (! pred (*first1, *first2))
return false;
return first1 == last1 && first2 == last2;
}
template <class Pred, class RanIt1, class RanIt2>
bool equal (RanIt1 first1, RanIt1 last1,
RanIt2 first2, RanIt2 last2, Pred pred,
random_access_iterator_tag,
random_access_iterator_tag )
{
if (std::distance (first1, last1) !=
std::distance (first2, last2))
return false;
for (; first1 != last1; ++first1, ++first2)
if (! pred (*first1, *first2))
return false;
return true;
}
}
/** C++14 implementation of std::equal. */
/** @{ */
template <class FwdIt1, class FwdIt2>
bool equal (FwdIt1 first1, FwdIt1 last1,
FwdIt2 first2, FwdIt2 last2)
{
return std::detail::equal (first1, last1,
first2, last2, std::equal_to <void>(),
typename std::iterator_traits <
FwdIt1>::iterator_category(),
typename std::iterator_traits <
FwdIt2>::iterator_category());
}
template <class FwdIt1, class FwdIt2, class Pred>
bool equal (FwdIt1 first1, FwdIt1 last1,
FwdIt2 first2, FwdIt2 last2, Pred pred)
{
return std::detail::equal <
typename std::add_lvalue_reference <Pred>::type> (
first1, last1, first2, last2, pred,
typename std::iterator_traits <
FwdIt1>::iterator_category(),
typename std::iterator_traits <
FwdIt2>::iterator_category());
}
/** @} */
}
#endif

51
beast/equal_to.h Normal file
View File

@@ -0,0 +1,51 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_EQUAL_TO_H_INCLUDED
#define BEAST_EQUAL_TO_H_INCLUDED
#include <functional>
#include <type_traits>
namespace std {
#ifndef _MSC_VER
/** C++14 implementation of std::equal_to <void> specialization.
This supports heterogeneous comparisons.
*/
template <>
struct equal_to <void>
{
// VFALCO NOTE Its not clear how to support is_transparent pre c++14
typedef std::true_type is_transparent;
template <class T, class U>
auto operator() (T&& lhs, U&& rhs) const ->
decltype (std::forward <T> (lhs) == std::forward <U> (rhs))
{
return std::forward <T> (lhs) == std::forward <U> (rhs);
}
};
#endif
}
#endif

76
beast/is_constructible.h Normal file
View File

@@ -0,0 +1,76 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Howard Hinnant <howard.hinnant@gmail.com>,
Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_IS_CONSTRUCTIBLE_H_INCLUDED
#define BEAST_IS_CONSTRUCTIBLE_H_INCLUDED
#include <type_traits>
#include <utility>
#include <tuple>
namespace std {
// Ideas from Howard Hinnant
//
// Specializations of is_constructible for pair and tuple which
// work around an apparent defect in the standard that causes well
// formed expressions involving pairs or tuples of non default-constructible
// types to generate compile errors.
//
template <class T, class U>
struct is_constructible <pair <T, U>>
: integral_constant <bool,
is_default_constructible <T>::value &&
is_default_constructible <U>::value>
{
};
namespace detail {
template <bool...>
struct compile_time_all;
template <>
struct compile_time_all <>
{
static const bool value = true;
};
template <bool Arg0, bool ... Argn>
struct compile_time_all <Arg0, Argn...>
{
static const bool value =
Arg0 && compile_time_all <Argn...>::value;
};
}
template <class ...T>
struct is_constructible <tuple <T...>>
: integral_constant <bool,
detail::compile_time_all <
is_default_constructible <T>::value...>::value>
{
};
}
#endif

View File

@@ -0,0 +1,38 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_TYPE_TRAITS_MAYBE_CONST_H_INCLUDED
#define BEAST_TYPE_TRAITS_MAYBE_CONST_H_INCLUDED
#include <type_traits>
namespace beast {
/** Makes T const or non const depending on a bool. */
template <bool IsConst, class T>
struct maybe_const
{
typedef typename std::conditional <IsConst,
typename std::remove_const <T>::type const,
typename std::remove_const <T>::type>::type type;
};
}
#endif

View File

@@ -0,0 +1,160 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 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 BEAST_UTILITY_EMPTY_BASE_OPTIMIZATION_H_INCLUDED
#define BEAST_UTILITY_EMPTY_BASE_OPTIMIZATION_H_INCLUDED
#include <type_traits>
#include <utility>
#ifndef BEAST_NO_EMPTY_BASE_OPTIMIZATION
# if defined _MSC_VER
# define BEAST_NO_EMPTY_BASE_OPTIMIZATION 1
# else
# define BEAST_NO_EMPTY_BASE_OPTIMIZATION 1
# endif
#endif
namespace beast {
namespace detail {
#if ! BEAST_NO_EMPTY_BASE_OPTIMIZATION
template <class T>
struct empty_base_optimization_decide
: std::integral_constant <bool,
std::is_empty <T>::value
#ifdef __clang__
&& !__is_final(T)
#endif
>
{
};
#else
template <class T>
struct empty_base_optimization_decide
: std::false_type
{
};
#endif
}
//------------------------------------------------------------------------------
template <
class T,
int UniqueID = 0,
bool ShouldDeriveFrom =
detail::empty_base_optimization_decide <T>::value
>
class empty_base_optimization : private T
{
public:
template <
class... Args,
class = typename std::enable_if <
std::is_constructible <T, Args...>::value>::type
>
explicit /*constexpr*/ empty_base_optimization (
Args&&... args)
/*noexcept (std::is_nothrow_constructible <T, Args...>::value);*/
: T (std::forward <Args> (args)...)
{
}
#if 1
empty_base_optimization (T const& t)
: T (t)
{
}
empty_base_optimization (T&& t)
: T (std::move (t))
{
}
empty_base_optimization& operator= (
empty_base_optimization const& other)
{
*this = other;
return *this;
}
empty_base_optimization& operator= (
empty_base_optimization&& other)
{
*this = std::move (other);
return *this;
}
#endif
T& member() noexcept
{
return *this;
}
T const& member() const noexcept
{
return *this;
}
};
//------------------------------------------------------------------------------
template <
class T,
int UniqueID
>
class empty_base_optimization <T, UniqueID, false>
{
public:
template <
class... Args,
class = typename std::enable_if <
std::is_constructible <T, Args...>::value>::type
>
explicit /*constexpr*/ empty_base_optimization (
Args&&... args)
/*noexcept (std::is_nothrow_constructible <T, Args...>::value);*/
: m_t (std::forward <Args> (args)...)
{
}
T& member() noexcept
{
return m_t;
}
T const& member() const noexcept
{
return m_t;
}
private:
T m_t;
};
}
#endif

View File

@@ -336,9 +336,9 @@ PropertyStream::Source* PropertyStream::Source::find_one_deep (std::string const
if (found != nullptr)
return found;
SharedState::Access state (this->m_state);
for (auto iter : state->children)
for (auto& s : state->children)
{
found = iter.source().find_one_deep (name);
found = s.source().find_one_deep (name);
if (found != nullptr)
return found;
}
@@ -366,10 +366,10 @@ PropertyStream::Source* PropertyStream::Source::find_path (std::string path)
PropertyStream::Source* PropertyStream::Source::find_one (std::string const& name)
{
SharedState::Access state (this->m_state);
for (auto iter : state->children)
for (auto& s : state->children)
{
if (iter.source().m_name == name)
return &iter.source();
if (s.source().m_name == name)
return &s.source();
}
return nullptr;
}