openMSX
Public Member Functions | List of all members
openmsx::Creator< T > Struct Template Reference

Utility to do T* t = new T(...) More...

#include <serialize_meta.hh>

Public Member Functions

template<typename TUPLE >
std::unique_ptr< T > operator() (TUPLE tuple)
 

Detailed Description

template<typename T>
struct openmsx::Creator< T >

Utility to do T* t = new T(...)

The tricky part is that the constructor of T can have a variable number of parameters.

For example: Creator<Foo> creator; auto args = std::tuple(42, 3.14); std::unique_ptr<Foo> foo = creator(args); This is equivalent to auto foo = std::make_unique<Foo>(42, 3.14); But the former can be used in a generic context (where the number of constructor parameters is unknown).

Definition at line 29 of file serialize_meta.hh.

Member Function Documentation

◆ operator()()

template<typename T >
template<typename TUPLE >
std::unique_ptr< T > openmsx::Creator< T >::operator() ( TUPLE  tuple)
inline

Definition at line 32 of file serialize_meta.hh.


The documentation for this struct was generated from the following file: