async_mqtt 5.0.0
Loading...
Searching...
No Matches
shared_ptr_array.hpp
1// Copyright Takatoshi Kondo 2022
2//
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7#if !defined(ASYNC_MQTT_UTIL_SHARED_PTR_ARRAY_HPP)
8#define ASYNC_MQTT_UTIL_SHARED_PTR_ARRAY_HPP
9
10#if defined(_DOXYGEN_)
11
20using shared_ptr_array = std::shared_ptr<char []>;
21using const_shared_ptr_array = std::shared_ptr<char const []>;
22
34inline shared_ptr_array make_shared_ptr_array(std::size_t size);
35
36#else // defined(_DOXYGEN_)
37
38
39#include <memory>
40
41namespace async_mqtt {
42
43using shared_ptr_array = std::shared_ptr<char []>;
44using const_shared_ptr_array = std::shared_ptr<char const []>;
45
46inline shared_ptr_array make_shared_ptr_array(std::size_t size) {
47#if __cpp_lib_shared_ptr_arrays >= 201707L
48 return std::make_shared<char[]>(size);
49#else // __cpp_lib_shared_ptr_arrays >= 201707L
50 return std::shared_ptr<char[]>(new char[size]);
51#endif // __cpp_lib_shared_ptr_arrays >= 201707L
52}
53
54} // namespace async_mqtt
55
56
57#endif // defined(_DOXYGEN_)
58
59#endif // ASYNC_MQTT_UTIL_SHARED_PTR_ARRAY_HPP