can you achieve the same thing without template specialization?

Let’s say I need to make a type that accepts a new types the same way as the containers work. Can I achieve the same thing without push_back type uses template specialization? #include <iostream> template <typename…> struct type_list {}; template <typename T> struct my_type { using type = T; }; template <typename LIST, typename T>… Read More can you achieve the same thing without template specialization?

Passing lambda as an argument to a function with std::function parameter with an arbitrary number of parameters

Consider the next sample of the code: template <typename… TArgs> void foo(std::function<void(TArgs…)> f) { } template <typename… TArgs> class Class { public: static void foo(std::function<void(TArgs…)> f) { } }; Why can I do this: int main() { // Helper class call Class<int, int>::foo( [](int a, int b) {} ); } But I get a compile… Read More Passing lambda as an argument to a function with std::function parameter with an arbitrary number of parameters

Rust macro with optional attribute statements over fields

I am trying to make a macro that modifies the declaration of a struct, for now I have this: macro_rules! Reflect { (pub struct $name:ident {$($field_name:ident : $field_type:ty,) *}) => { #[derive(Debug, Clone, serde::Serialize)] #[serde(rename_all = "camelCase")] pub struct $name { $(pub $field_name : $field_type,) * } } Reflect!( pub struct Node { name :… Read More Rust macro with optional attribute statements over fields

Python dynamic function & parameters call – str object is not callable

I´m trying to come up with a dynamic function calling system. I have a database with a bunch of differents levels: Decision Evaluator > Function (response curve) parameters > Inputs. Choosing a Decision Evaluator may call 10 different functions but only 5 inputs, treated differently through the parameters. So it would be way easier to… Read More Python dynamic function & parameters call – str object is not callable

How to get a removed-reference tuple type without using an instance in C++

I wrote a test framework for testing function output (see code below). template <class FuncTy, class… IndexType> typename std::enable_if<std::tuple_size<typename function_helper<FuncTy>::arguments>::value == sizeof…(IndexType) and std::is_same_v<typename function_helper<FuncTy>::return_type, AnswerTy> and not is_member_function_pointer_v<FuncTy>, void>::type test(FuncTy func, IndexType… arg_indexes) { using function_args_tuple = typename function_helper<FuncTy>::arguments; using function_return_type = typename function_helper<FuncTy>::return_type; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> function_args_tuple params; /// error is here // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<… Read More How to get a removed-reference tuple type without using an instance in C++