gimo v0.1.0
Loading...
Searching...
No Matches
StdSharedPtr.hpp
Go to the documentation of this file.
1// Copyright Dominic (DNKpp) Koepke 2025.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// https://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef GIMO_EXT_STD_SHARED_PTR_HPP
7#define GIMO_EXT_STD_SHARED_PTR_HPP
8
9#pragma once
10
11#include <memory>
12
13namespace gimo
14{
15 template <typename T>
16 struct traits;
17}
18
19template <typename T>
20 requires(!std::is_array_v<T>)
21struct gimo::traits<std::shared_ptr<T>>
22{
23 static constexpr std::nullptr_t null{};
24
25 template <typename V>
26 using rebind_value = std::shared_ptr<V>;
27
28 template <typename Arg>
29 requires std::constructible_from<T, Arg&&>
30 [[nodiscard]]
31 static constexpr std::shared_ptr<T> from_value(Arg&& arg)
32 {
33 return std::make_shared<T>(std::forward<Arg>(arg));
34 }
35};
36
37#endif
Definition AndThen.hpp:21
std::shared_ptr< V > rebind_value
Definition StdSharedPtr.hpp:26
static constexpr std::nullptr_t null
Definition StdSharedPtr.hpp:23
static constexpr std::shared_ptr< T > from_value(Arg &&arg)
Definition StdSharedPtr.hpp:31
The central customization point for the library.
Definition Common.hpp:102