PLCnext API Documentation 25.0.2.69
PimplPtr.hxx
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
7#include <memory>
8namespace Arp { namespace Base { namespace Core
9{
10
13template<class T, bool Copyable = false>
15{
16private: // usings
17 using Impl = T;
18 using ImplPtr = std::unique_ptr<Impl>;
19
20public: // construction/destruction
21 template <class ...Args>
22 explicit PimplPtr(Args&& ... args);
23 PimplPtr(const PimplPtr& arg) = delete;
24 PimplPtr(PimplPtr&& arg)noexcept;
25 PimplPtr& operator=(const PimplPtr& arg) = delete;
26 PimplPtr& operator=(PimplPtr&& arg)noexcept;
27 ~PimplPtr(void);
28
29public: // operators
30 Impl* operator->(void);
31 const Impl* operator->(void)const;
32 Impl& operator*(void);
33 const Impl& operator*(void)const;
34 explicit operator bool(void)const noexcept;
35
36private: // fields
37 ImplPtr implPtr;
38};
39
42template<class T>
43class PimplPtr<T, true>
44{
45private: // usings
46 using Impl = T;
47 using ImplPtr = std::unique_ptr<Impl>;
48
49public: // construction/destruction
51 template <class ...Args>
52 explicit PimplPtr(Args&& ... args);
53 PimplPtr(const PimplPtr& arg);
54 PimplPtr(PimplPtr&& arg)noexcept;
55 PimplPtr& operator=(const PimplPtr& arg);
56 PimplPtr& operator=(PimplPtr&& arg)noexcept;
57 ~PimplPtr(void);
58
59public: // operators
60 Impl* operator->(void);
61 const Impl* operator->(void)const;
62 Impl& operator*(void);
63 const Impl& operator*(void)const;
64 explicit operator bool(void)const noexcept;
65
66private: // fields
67 ImplPtr implPtr;
68};
69
70}}} // end of namespace Arp::Base::Core
PimplPtr & operator=(PimplPtr &&arg) noexcept
Default assignment move operator.
~PimplPtr(void)
Default destructor.
PimplPtr(PimplPtr &&arg) noexcept
Default move constructor.
Adapter class to implement PImpl idiom.
Definition: PimplPtr.hxx:15
~PimplPtr(void)
Default destructor.
Impl & operator*(void)
Indirect operator to access pointee.
Definition: PimplPtr.inl:51
PimplPtr & operator=(PimplPtr &&arg) noexcept
Default assignment move operator.
PimplPtr(Args &&... args)
Variadic constructor.
Definition: PimplPtr.inl:18
Impl * operator->(void)
Arrow operator to access pointee.
Definition: PimplPtr.inl:37
PimplPtr(PimplPtr &&arg) noexcept
Default move constructor.
Root namespace for the PLCnext API