GQCP
Loading...
Searching...
No Matches
memory.hpp
Go to the documentation of this file.
1// This file is part of GQCG-GQCP.
2//
3// Copyright (C) 2017-2020 the GQCG developers
4//
5// GQCG-GQCP is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GQCG-GQCP is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GQCG-GQCP. If not, see <http://www.gnu.org/licenses/>.
17
18#pragma once
19
20
26#include <cstddef>
27#include <memory>
28#include <type_traits>
29#include <utility>
30
31
36namespace GQCP {
37
38
39template <class T>
40struct _Unique_if {
41 using _Single_object = std::unique_ptr<T>;
42};
43
44
45template <class T>
46struct _Unique_if<T[]> {
47 using _Unknown_bound = std::unique_ptr<T[]>;
48};
49
50
51template <class T, size_t N>
52struct _Unique_if<T[N]> {
53 using _Known_bound = void;
54};
55
56
57template <class T, class... Args>
59 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
60}
61
62
63template <class T>
65 using U = typename std::remove_extent<T>::type;
66 return std::unique_ptr<T>(new U[n]());
67}
68
69
70template <class T, class... Args>
71typename _Unique_if<T>::_Known_bound make_unique(Args&&...) = delete;
72
73
74} // namespace GQCP
Definition: BaseOneElectronIntegralBuffer.hpp:25
_Unique_if< T >::_Single_object make_unique(Args &&... args)
Definition: memory.hpp:58
std::unique_ptr< T[]> _Unknown_bound
Definition: memory.hpp:47
void _Known_bound
Definition: memory.hpp:53
Definition: memory.hpp:40
std::unique_ptr< T > _Single_object
Definition: memory.hpp:41