PLCnext API Documentation 24.0.0.71
PimplPtr.hxx
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include <memory>
9
10namespace Arp
11{
12
14template<class T, bool Copyable = false>
16{
17public: // usings
18 using Impl = T;
19 using ImplPtr = std::unique_ptr<Impl>;
20
21public: // construction/destruction
23 template <class ...Args>
24 ARP_CXX_SYMBOL_EXPORT explicit PimplPtr(Args&& ... args);
26 PimplPtr(const PimplPtr& arg) = delete;
28 ARP_CXX_SYMBOL_EXPORT PimplPtr(PimplPtr&& arg)noexcept;
30 PimplPtr& operator=(const PimplPtr& arg) = delete;
32 ARP_CXX_SYMBOL_EXPORT PimplPtr& operator=(PimplPtr&& arg)noexcept;
34 ARP_CXX_SYMBOL_EXPORT ~PimplPtr(void);
35
36public: // operators
38 ARP_CXX_SYMBOL_EXPORT Impl* operator->(void);
40 ARP_CXX_SYMBOL_EXPORT const Impl* operator->(void)const;
42 ARP_CXX_SYMBOL_EXPORT Impl& operator*(void);
44 ARP_CXX_SYMBOL_EXPORT const Impl& operator*(void)const;
46 ARP_CXX_SYMBOL_EXPORT explicit operator bool(void)const noexcept;
47
48private: // fields
49 ImplPtr implPtr;
50};
51
52template<class T>
53class PimplPtr<T, true>
54{
55public: // usings
56 using Impl = T;
57 using ImplPtr = std::unique_ptr<Impl>;
58
59public: // construction/destruction
61 template <class ...Args>
62 ARP_CXX_SYMBOL_EXPORT explicit PimplPtr(Args&& ... args);
64 ARP_CXX_SYMBOL_EXPORT PimplPtr(const PimplPtr& arg);
66 ARP_CXX_SYMBOL_EXPORT PimplPtr(PimplPtr&& arg)noexcept;
68 ARP_CXX_SYMBOL_EXPORT PimplPtr& operator=(const PimplPtr& arg);
70 ARP_CXX_SYMBOL_EXPORT PimplPtr& operator=(PimplPtr&& arg)noexcept;
72 ARP_CXX_SYMBOL_EXPORT ~PimplPtr(void);
73
74public: // operators
76 ARP_CXX_SYMBOL_EXPORT Impl* operator->(void);
78 ARP_CXX_SYMBOL_EXPORT const Impl* operator->(void)const;
80 ARP_CXX_SYMBOL_EXPORT Impl& operator*(void);
82 ARP_CXX_SYMBOL_EXPORT const Impl& operator*(void)const;
84 ARP_CXX_SYMBOL_EXPORT explicit operator bool(void) const noexcept;
85
86private: // fields
87 ImplPtr implPtr;
88};
89
90} // end of namespace Arp
ARP_CXX_SYMBOL_EXPORT ~PimplPtr(void)
Destructs this instance and frees all resources.
ARP_CXX_SYMBOL_EXPORT PimplPtr & operator=(PimplPtr &&arg) noexcept
Assignment move operator.
ARP_CXX_SYMBOL_EXPORT PimplPtr(Args &&... args)
Constructs an PImpl instance using the supplied arguments.
ARP_CXX_SYMBOL_EXPORT const Impl & operator*(void) const
Gets the reference to the const Impl instance for const objects.
ARP_CXX_SYMBOL_EXPORT PimplPtr(PimplPtr &&arg) noexcept
Move constructor.
ARP_CXX_SYMBOL_EXPORT const Impl * operator->(void) const
Gets the pointer to the const Impl instance for const objects.
Small wrapper class to ensure const correctness using PImpl pattern.
Definition: PimplPtr.hxx:16
ARP_CXX_SYMBOL_EXPORT Impl & operator*(void)
Gets the reference to the Impl instance for none const objects.
Definition: PimplPtr.inl:51
ARP_CXX_SYMBOL_EXPORT ~PimplPtr(void)
Destructs this instance and frees all resources.
ARP_CXX_SYMBOL_EXPORT PimplPtr & operator=(PimplPtr &&arg) noexcept
Assignment move operator.
ARP_CXX_SYMBOL_EXPORT PimplPtr(Args &&... args)
Constructs an PImpl instance using the supplied arguments.
ARP_CXX_SYMBOL_EXPORT Impl * operator->(void)
Gets the pointer to the Impl instance for none const objects.
Definition: PimplPtr.inl:37
ARP_CXX_SYMBOL_EXPORT const Impl * operator->(void) const
Gets the pointer to the const Impl instance for const objects.
ARP_CXX_SYMBOL_EXPORT PimplPtr(PimplPtr &&arg) noexcept
Move constructor.
PimplPtr(const PimplPtr &arg)=delete
Copy constructor.
ARP_CXX_SYMBOL_EXPORT const Impl & operator*(void) const
Gets the reference to the const Impl instance for const objects.
PimplPtr & operator=(const PimplPtr &arg)=delete
Assignment operator.
Root namespace for the PLCnext API