13#include <lagrange/utils/assert.h>
14#include <lagrange/utils/strings.h>
15#include <lagrange/utils/warning.h>
30template <
typename F,
typename Result,
typename...
Args>
33 using fn_type = std::function<Result(
Args...)>;
44template <
class Class,
class ReturnType,
class Arg>
50template <
class ReturnType,
class Arg>
56template <
class ReturnType,
class Arg>
70 using type = std::conditional_t<std::is_same<T, const char*>::value, std::string, T>;
74using convert_implicit_t =
typename convert_implicit<T>::type;
77template <
typename...
Args>
80 using type = std::tuple<std::remove_cv_t<std::remove_reference_t<convert_implicit_t<Args>>>...>;
83template <
typename...
Args>
88std::unique_ptr<T> realize_default(
89 typename std::enable_if<std::is_default_constructible<T>::value>::type* dummy = 0)
92 return std::make_unique<T>();
96std::unique_ptr<T> realize_default(
97 typename std::enable_if<!std::is_default_constructible<T>::value>::type* dummy = 0)
104 "Cannot default construct type {}, provide a realization function to ResourceFactory",
110template <
typename T,
typename... Dummy>
111std::shared_ptr<T> realize_forward(
const std::shared_ptr<T>& ptr)
116template <
typename T,
typename...
Args>
117std::shared_ptr<T> realize_forward(
119 typename std::enable_if<std::is_constructible<T, Args...>::value>::type* dummy = 0)
122 return std::make_shared<T>(std::forward<Args>(args)...);
125template <
typename...
Args>
126void unused_variadic(
Args&&... args)
138template <
typename T,
typename...
Args>
139std::shared_ptr<T> realize_forward(
141 typename std::enable_if<
142 !std::is_constructible<T, Args...>::value &&
143 !std::is_constructible<std::shared_ptr<T>,
Args...>::value &&
144 !std::is_constructible<std::unique_ptr<T>,
Args...>::value>::type* dummy = 0)
147 unused_variadic(std::forward<Args>(args)...);
151 "Cannot construct type {} from given arguments {}, provide a realization function to "
154 typeid(std::tuple<Args...>).name()));
160template <
typename T_out,
typename T_in>
161T_out copy_or_move_element(
163 typename std::enable_if<!std::is_rvalue_reference<T_out>::value>::type* dummy = 0)
170template <
typename T_out,
typename T_in>
171std::remove_reference_t<T_out> copy_or_move_element(
173 typename std::enable_if<std::is_rvalue_reference<T_out>::value>::type* dummy = 0)
176 std::remove_reference_t<T_out> moved = std::move(in);
181template <
typename ArgumentTuple,
typename... Ts,
size_t... Is>
182auto copy_or_move_impl(std::tuple<Ts...>& input, std::index_sequence<Is...>)
184 return std::tuple<Ts...>{
185 copy_or_move_element<std::tuple_element_t<Is, ArgumentTuple>>(std::get<Is>(input))...};
189template <
typename ArgumentTuple,
typename... Ts>
190std::tuple<Ts...> copy_or_move(std::tuple<Ts...>& input)
192 return copy_or_move_impl<ArgumentTuple>(input, std::make_index_sequence<
sizeof...(Ts)>{});
195template <
typename ParamPack,
typename ParamPackOriginal,
typename F>
196void apply_parameters(
199 typename std::enable_if<std::is_constructible<ParamPack, const ParamPack&>::value>::type*
204 auto& storage_tuple = std::any_cast<ParamPack&>(storage);
205 auto forwarded_tuple = copy_or_move<ParamPackOriginal>(storage_tuple);
207 std::apply(fn, std::move(forwarded_tuple));
211template <
typename ParamPack,
typename ParamPackOriginal,
typename F>
212void apply_parameters(
215 typename std::enable_if<!std::is_constructible<ParamPack, const ParamPack&>::value>::type*
#define la_runtime_assert(...)
Runtime assertion check.
Definition: assert.h:169
std::string string_format(fmt::format_string< Args... > format, Args &&... args)
Format args according to the format string fmt, and return the result as a string.
Definition: strings.h:103
#define LA_IGNORE(x)
Ignore x to avoid an unused variable warning.
Definition: warning.h:136
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Definition: project.cpp:27
Definition: template.h:79
Definition: template.h:69
Definition: template.h:41
Definition: template.h:28