File indexing completed on 2024-05-19 05:33:31

0001 /*
0002     SPDX-FileCopyrightText: 2019 Ivan Čukić <ivan.cukic(at)kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef UTILS_CONSTRUCTOR_FN_H
0008 #define UTILS_CONSTRUCTOR_FN_H
0009 
0010 #include <type_traits>
0011 
0012 template <typename R>
0013 struct construct {
0014     template <typename... Args>
0015     R operator() (Args&&... args) const
0016         noexcept(std::is_nothrow_constructible_v<R, Args&&...>)
0017     {
0018         return R(std::forward<Args>(args)...);
0019     }
0020 };
0021 
0022 template <typename R>
0023 struct initialize {
0024     template <typename... Args>
0025     R operator() (Args&&... args) const
0026         noexcept(std::is_nothrow_constructible_v<R, Args&&...>)
0027     {
0028         return R{std::forward<Args>(args)...};
0029     }
0030 };
0031 
0032 #endif // include guard
0033