diff --git a/functor.hpp b/functor.hpp index 8ad31dfb..9b0e4f85 100644 --- a/functor.hpp +++ b/functor.hpp @@ -3,12 +3,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * Copyright 2018 Danny Robson + * Copyright 2018-2019 Danny Robson */ #pragma once #include +#include namespace cruft::functor { @@ -69,4 +70,33 @@ namespace cruft::functor { //------------------------------------------------------------------------- template constant (ValueT) -> constant>; -}; \ No newline at end of file + + + /////////////////////////////////////////////////////////////////////////// + /// Returns a ValueT constructed from the supplied arguments. + template + struct construct { + template + ValueT operator() (Args &&...args) + { + return ValueT { + std::forward (args)... + }; + } + }; + + + ///------------------------------------------------------------------------ + /// Returns a ValueT constructed from a tuple of arguments. + template + struct tuple_construct { + template + ValueT operator() (Args &&args) + { + return std::apply ( + construct {}, + std::forward (args) + ); + } + }; +} \ No newline at end of file