Warning, file /include/boost/unordered/detail/allocator_constructed.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_UNORDERED_DETAIL_ALLOCATOR_CONSTRUCTED_HPP
0010 #define BOOST_UNORDERED_DETAIL_ALLOCATOR_CONSTRUCTED_HPP
0011
0012 #include <boost/core/allocator_traits.hpp>
0013 #include <boost/unordered/detail/opt_storage.hpp>
0014
0015 namespace boost {
0016 namespace unordered {
0017 namespace detail {
0018
0019 struct allocator_policy
0020 {
0021 template <class Allocator, class T, class... Args>
0022 static void construct(Allocator& a, T* p, Args&&... args)
0023 {
0024 boost::allocator_construct(a, p, std::forward<Args>(args)...);
0025 }
0026
0027 template <class Allocator, class T>
0028 static void destroy(Allocator& a, T* p)
0029 {
0030 boost::allocator_destroy(a, p);
0031 }
0032 };
0033
0034
0035 template <class Allocator, class T, class Policy = allocator_policy>
0036 class allocator_constructed
0037 {
0038 opt_storage<T> storage;
0039 Allocator alloc;
0040
0041 public:
0042 template <class... Args>
0043 allocator_constructed(Allocator const& alloc_, Args&&... args)
0044 : alloc(alloc_)
0045 {
0046 Policy::construct(
0047 alloc, storage.address(), std::forward<Args>(args)...);
0048 }
0049
0050 ~allocator_constructed() { Policy::destroy(alloc, storage.address()); }
0051
0052 T& value() { return *storage.address(); }
0053 };
0054
0055 }
0056 }
0057 }
0058
0059 #endif