Sayonara Player
Pimpl.h
1/* Pimpl.h */
2
3/* Copyright (C) 2011-2020 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
38#define PIMPL(Class) private: \
39 struct Private; \
40 friend struct Private; \
41 std::unique_ptr< Class ::Private> m; \
42 private:
43
47namespace Pimpl
48{
49 template<typename T, typename... Args>
55 std::unique_ptr<T> make(Args&&... args)
56 {
57 return std::unique_ptr<T>(
58 new T(std::forward<Args>(args)...)
59 );
60 }
61}
62
63#endif // SAYONARA_PIMPL_H_
Definition: Pimpl.h:48
std::unique_ptr< T > make(Args &&... args)
make create an instance of the ::Private structure
Definition: Pimpl.h:55