alpaqa
1.0.0a18
Nonconvex constrained optimization
Loading...
Searching...
No Matches
src
alpaqa
include
alpaqa
util
copyable_unique_ptr.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <memory>
4
5
namespace
alpaqa::util
{
6
7
template
<
class
T>
8
struct
copyable_unique_ptr
{
9
copyable_unique_ptr
(std::unique_ptr<T>
ptr
) :
ptr
{std::move(
ptr
)} {}
10
copyable_unique_ptr
() =
default
;
11
copyable_unique_ptr
(
const
copyable_unique_ptr
&
o
)
12
:
ptr
{
o
.
ptr
? std::
make_unique
<
T
>(*
o
.
ptr
) :
nullptr
} {}
13
copyable_unique_ptr
&
operator=
(
const
copyable_unique_ptr
&
o
) {
14
this->
ptr
= o.
ptr
? std::make_unique<T>(*
o
.ptr) :
nullptr
;
15
return
*
this
;
16
}
17
copyable_unique_ptr
(
copyable_unique_ptr
&&)
noexcept
=
default
;
18
copyable_unique_ptr
&
operator
=(
copyable_unique_ptr
&&)
noexcept
=
default
;
19
20
operator
std::
unique_ptr
<
T
> &() & {
return
ptr
; }
21
operator
const
std::unique_ptr<T> &()
const
& {
return
ptr
; }
22
operator
std::unique_ptr<T> &&() && {
return
std::move(
ptr
); }
23
24
std::unique_ptr<T> &
operator->
() {
return
ptr
; }
25
const
std::unique_ptr<T> &
operator->
()
const
{
return
ptr
; }
26
auto
&
operator*
() {
return
*
ptr
; }
27
auto
&
operator*
()
const
{
return
*
ptr
; }
28
29
std::unique_ptr<T>
ptr
;
30
};
31
32
}
// namespace alpaqa::util
alpaqa::util
Definition
check-dim.hpp:8
alpaqa::inf
constexpr const auto inf
Definition
config.hpp:112
alpaqa::util::copyable_unique_ptr
Definition
copyable_unique_ptr.hpp:8
alpaqa::util::copyable_unique_ptr::operator=
copyable_unique_ptr & operator=(const copyable_unique_ptr &o)
Definition
copyable_unique_ptr.hpp:13
alpaqa::util::copyable_unique_ptr::copyable_unique_ptr
copyable_unique_ptr(copyable_unique_ptr &&) noexcept=default
alpaqa::util::copyable_unique_ptr::copyable_unique_ptr
copyable_unique_ptr(const copyable_unique_ptr &o)
Definition
copyable_unique_ptr.hpp:11
alpaqa::util::copyable_unique_ptr::operator->
std::unique_ptr< T > & operator->()
Definition
copyable_unique_ptr.hpp:24
alpaqa::util::copyable_unique_ptr::ptr
std::unique_ptr< T > ptr
Definition
copyable_unique_ptr.hpp:29
alpaqa::util::copyable_unique_ptr::operator*
auto & operator*() const
Definition
copyable_unique_ptr.hpp:27
alpaqa::util::copyable_unique_ptr::operator*
auto & operator*()
Definition
copyable_unique_ptr.hpp:26
alpaqa::util::copyable_unique_ptr::copyable_unique_ptr
copyable_unique_ptr(std::unique_ptr< T > ptr)
Definition
copyable_unique_ptr.hpp:9
alpaqa::util::copyable_unique_ptr::copyable_unique_ptr
copyable_unique_ptr()=default
alpaqa::util::copyable_unique_ptr::operator->
const std::unique_ptr< T > & operator->() const
Definition
copyable_unique_ptr.hpp:25
Generated on Wed Mar 27 2024 for alpaqa by
1.9.8