libcopp  2.2.0
standard_new_allocator.h
Go to the documentation of this file.
1 // Copyright 2023 owent
2 
3 #pragma once
4 
5 #include <libcopp/utils/config/libcopp_build_features.h>
6 
8 
9 // clang-format off
10 #include <libcopp/utils/config/stl_include_prefix.h> // NOLINT(build/include_order)
11 // clang-format on
12 #include <memory>
13 // clang-format off
14 #include <libcopp/utils/config/stl_include_suffix.h> // NOLINT(build/include_order)
15 // clang-format on
16 
17 LIBCOPP_COTASK_NAMESPACE_BEGIN
18 namespace core {
19 class LIBCOPP_COTASK_API_HEAD_ONLY standard_new_allocator {
20  public:
26  template <class Ty, class... TARGS>
27  static std::shared_ptr<Ty> allocate(Ty *, TARGS &&...args) {
28  return std::make_shared<Ty>(std::forward<TARGS>(args)...);
29  }
30 
31  template <class Ty>
32  static void deallocate(std::shared_ptr<Ty> &) {}
33 };
34 } // namespace core
35 LIBCOPP_COTASK_NAMESPACE_END
static void deallocate(std::shared_ptr< Ty > &)
static std::shared_ptr< Ty > allocate(Ty *, TARGS &&...args)
allocate a object