File indexing completed on 2024-05-05 04:59:26

0001 /*
0002  *   SPDX-FileCopyrightText: 2012-2016 Ivan Cukic <ivan.cukic@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef D_PTR_H
0008 #define D_PTR_H
0009 
0010 #include <memory>
0011 
0012 namespace kamd
0013 {
0014 namespace utils
0015 {
0016 
0017 template<typename T>
0018 class d_ptr
0019 {
0020 private:
0021     std::unique_ptr<T> d;
0022 
0023 public:
0024     d_ptr();
0025 
0026     template<typename... Args>
0027     d_ptr(Args &&...);
0028 
0029     ~d_ptr();
0030 
0031     T *operator->() const;
0032 };
0033 
0034 #define D_PTR                                                                                                                                                  \
0035     class Private;                                                                                                                                             \
0036     friend class Private;                                                                                                                                      \
0037     const ::kamd::utils::d_ptr<Private> d
0038 
0039 #define D_PTRC(cls)                                                                                                                                            \
0040     friend class cls;                                                                                                                                          \
0041     const ::kamd::utils::d_ptr<cls> d
0042 
0043 } // namespace utils
0044 } // namespace kamd
0045 
0046 #endif