Sayonara Player
Loading...
Searching...
No Matches
Pimpl.h
1/* Pimpl.h */
2
3/* Copyright (C) 2011-2024 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#ifndef SAYONARA_PIMPL_H_
24#define SAYONARA_PIMPL_H_
25
26#include <memory>
27#include <utility>
28
29#include "Utils/typedefs.h"
30
31#define CASSIGN(x) x(other.x)
32#define CMOVE(x) x(std::move(other.x))
33#define ASSIGN(x) x = other.x
34#define MOVE(x) x = std::move(other.x)
35#define CMP(x) (x == other.x)
36
37#define PIMPL(Class) private: \
38 struct Private; \
39 friend struct Private; \
40 std::unique_ptr< Class ::Private> m; \
41 private:
42
46namespace Pimpl
47{
48 template<typename T, typename... Args>
54 std::unique_ptr<T> make(Args&& ... args)
55 {
56 return std::unique_ptr<T>(
57 new T(std::forward<Args>(args)...)
58 );
59 }
60}
61
62#endif // SAYONARA_PIMPL_H_
Definition Pimpl.h:47
std::unique_ptr< T > make(Args &&... args)
make create an instance of the Private structure
Definition Pimpl.h:54