template<class T>
Make struct
Factory template for perfect forwarding construction.
Template parameters | |
---|---|
T | The type to construct. |
The Make template provides a function object that constructs instances of type T using perfect forwarding to preserve value categories of arguments. This is particularly useful in template metaprogramming where construction needs to be performed within template contexts.
The Make template serves as a type-safe factory that ensures proper forwarding semantics and can be used in situations where direct construction is not possible or convenient.
Example usage:
auto factory = Make<std::vector<int>>{}; auto vec = factory(10, 42); // Creates std::vector<int>(10, 42) // Used in template contexts: template<typename T, typename... Args> auto createInstance(Args&&... args) { return Make<T>{}(std::forward<Args>(args)...); }
Public functions
-
template<class ... Params>auto operator()(Params && ... params) -> T
- Constructs an instance of T using perfect forwarding.
Function documentation
template<class T>
template<class ... Params>
T Rodin:: Utility:: Make<T>:: operator()(Params && ... params)
Constructs an instance of T using perfect forwarding.
Template parameters | |
---|---|
Params | Parameter pack of constructor argument types. |
Parameters | |
params | Constructor arguments to forward to T's constructor. |
Returns | A new instance of T constructed with the forwarded parameters. |
This operator uses perfect forwarding to preserve the value categories of the arguments, ensuring optimal performance and correct semantics for both lvalue and rvalue arguments.