My Project
construct_at.hpp
Go to the documentation of this file.
1 
28 #ifndef BSL_CONSTRUCT_AT_HPP
29 #define BSL_CONSTRUCT_AT_HPP
30 
31 #include "discard.hpp"
32 #include "declval.hpp"
33 #include "forward.hpp"
34 
35 #ifndef PERFORCE
36 
46 constexpr void *
47 operator new(bsl::uintmax count, void *ptr) noexcept // PRQA S 1-10000
48 {
49  bsl::discard(count);
50  return ptr;
51 }
52 
53 namespace std // NOLINT
54 {
78  template<typename T, typename... ARGS>
79  constexpr void
80  construct_at_impl(void *const ptr, ARGS &&... args) // --
81  noexcept(noexcept(new (ptr) T{bsl::declval<ARGS>()...}))
82  {
83  if (nullptr == ptr) {
84  return;
85  }
86 
87  bsl::discard(new (ptr) T{bsl::forward<ARGS>(args)...}); // NOLINT // PRQA S 1-10000
88  }
89 }
90 
91 namespace bsl
92 {
106  template<typename T, typename... ARGS>
107  constexpr void
108  construct_at(void *const ptr, ARGS &&... args) // --
109  noexcept(noexcept(std::construct_at_impl<T, ARGS...>(ptr, bsl::declval<ARGS>()...)))
110  {
111  std::construct_at_impl<T, ARGS...>(ptr, bsl::forward<ARGS>(args)...);
112  }
113 }
114 
115 #else
116 
117 namespace bsl
118 {
129  template<typename T, typename... ARGS>
130  constexpr void
131  construct_at(void *ptr, ARGS &&... args) noexcept
132  {
133  bsl::discard(ptr);
134  bsl::discard(bsl::forward<ARGS>(args)...);
135  }
136 }
137 
138 #endif
139 
140 #endif
constexpr void discard(ARGS &&... args) noexcept
This function discards a parameter that it is given. This is the same as executing a static cast....
Definition: discard.hpp:58
constexpr void construct_at_impl(void *const ptr, ARGS &&... args) noexcept(noexcept(new(ptr) T{bsl::declval< ARGS >()...}))
Implements a constexpr version of placement new. that can be used by BSL's APIs to support constexpr ...
Definition: construct_at.hpp:80
constexpr void construct_at(void *const ptr, ARGS &&... args) noexcept(noexcept(std::construct_at_impl< T, ARGS... >(ptr, bsl::declval< ARGS >()...)))
Implements a constexpr version of placement new. that can be used by BSL's APIs to support constexpr ...
Definition: construct_at.hpp:108
::uintmax_t uintmax
defines a unsigned integer with the maximum possible size
Definition: cstdint.hpp:97