PLCnext API Documentation 25.0.2.69
PimplPtr.hxx
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
7
8#ifndef ARP_USE_ARP_SYSTEM_CORE
9
10#include "Arp/Base/Core/PimplPtr.hxx"
11
12#else
13
14#include "Arp/System/Core/Arp.h"
15#include <memory>
16
17namespace Arp
18{
19
21template<class T, bool Copyable = false>
22class PimplPtr
23{
24public: // usings
25 using Impl = T;
26 using ImplPtr = std::unique_ptr<Impl>;
27
28public: // construction/destruction
30 template <class ...Args>
31 ARP_CXX_SYMBOL_EXPORT explicit PimplPtr(Args&& ... args);
33 PimplPtr(const PimplPtr& arg) = delete;
35 ARP_CXX_SYMBOL_EXPORT PimplPtr(PimplPtr&& arg)noexcept;
37 PimplPtr& operator=(const PimplPtr& arg) = delete;
39 ARP_CXX_SYMBOL_EXPORT PimplPtr& operator=(PimplPtr&& arg)noexcept;
41 ARP_CXX_SYMBOL_EXPORT ~PimplPtr(void);
42
43public: // operators
45 ARP_CXX_SYMBOL_EXPORT Impl* operator->(void);
47 ARP_CXX_SYMBOL_EXPORT const Impl* operator->(void)const;
49 ARP_CXX_SYMBOL_EXPORT Impl& operator*(void);
51 ARP_CXX_SYMBOL_EXPORT const Impl& operator*(void)const;
53 ARP_CXX_SYMBOL_EXPORT explicit operator bool(void)const noexcept;
54
55private: // fields
56 ImplPtr implPtr;
57};
58
59template<class T>
60class PimplPtr<T, true>
61{
62public: // usings
63 using Impl = T;
64 using ImplPtr = std::unique_ptr<Impl>;
65
66public: // construction/destruction
68 template <class ...Args>
69 ARP_CXX_SYMBOL_EXPORT explicit PimplPtr(Args&& ... args);
71 ARP_CXX_SYMBOL_EXPORT PimplPtr(const PimplPtr& arg);
73 ARP_CXX_SYMBOL_EXPORT PimplPtr(PimplPtr&& arg)noexcept;
75 ARP_CXX_SYMBOL_EXPORT PimplPtr& operator=(const PimplPtr& arg);
77 ARP_CXX_SYMBOL_EXPORT PimplPtr& operator=(PimplPtr&& arg)noexcept;
79 ARP_CXX_SYMBOL_EXPORT ~PimplPtr(void);
80
81public: // operators
83 ARP_CXX_SYMBOL_EXPORT Impl* operator->(void);
85 ARP_CXX_SYMBOL_EXPORT const Impl* operator->(void)const;
87 ARP_CXX_SYMBOL_EXPORT Impl& operator*(void);
89 ARP_CXX_SYMBOL_EXPORT const Impl& operator*(void)const;
91 ARP_CXX_SYMBOL_EXPORT explicit operator bool(void) const noexcept;
92
93private: // fields
94 ImplPtr implPtr;
95};
96
97} // end of namespace Arp
98
99#endif // ndef ARP_USE_ARP_SYSTEM_CORE
~PimplPtr(void)
Default destructor.
Impl & operator*(void)
Indirect operator to access pointee.
Definition: PimplPtr.inl:51
PimplPtr(Args &&... args)
Variadic constructor.
Definition: PimplPtr.inl:18
Impl * operator->(void)
Arrow operator to access pointee.
Definition: PimplPtr.inl:37
Root namespace for the PLCnext API