Sayonara Player
Pimpl.h
1 /* Pimpl.h */
2 
3 /* Copyright (C) 2011-2017 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 
28 #define PIMPL(Class) private: \
29  struct Private; \
30  friend struct Private; \
31  std::unique_ptr< Class ::Private> _m; \
32  private:
33 
37 namespace Pimpl
38 {
39  template<typename T, typename... Args>
45  std::unique_ptr<T> make(Args&&... args)
46  {
47  return std::unique_ptr<T>(
48  new T(std::forward<Args>(args)...)
49  );
50  }
51 }
52 
53 #endif // SAYONARA_PIMPL_H_
Definition: Pimpl.h:37
std::unique_ptr< T > make(Args &&... args)
make create an instance of the ::Private structure
Definition: Pimpl.h:45