Questions tagged [metaprogramming]
Metaprogramming is the capability to reprogram ones programming environment, as with macros or metaclasses.
4,814
questions
0
votes
1
answer
43
views
Template parameters for c++ multidimentional array [duplicate]
Can someone explain how the following base template and specialization is instantiated to produce the correct result? I'm particularly unclear on how the <U[N]> template parameter is interpreted....
-1
votes
1
answer
56
views
How to initialize a member by expanding tuple inside an member initializer list? [duplicate]
I am expanding an std::tuple in order to initialize a ranges::concat_view member as follows:
...
Bar(const std::tuple<Args...>& tpl, std::index_sequence<Idx,...>) :data{(std::get<...
0
votes
1
answer
38
views
Making a tuple of references out of another tuple by condition
I have a templated structure ContainerInner that has a tuple with vectors of types from its variadic template and a structure Container that contains a tuple of ContainerInner, specified in its ...
0
votes
2
answers
69
views
Is it possible to use a modified version of a class template parameter pack in a members template?
I am trying to write a class template with a variadic template parameter pack which is separated into two groups of arguments. Those shall be used in member templates.
template <class... Args>
...
0
votes
1
answer
134
views
How can I check if a certain function overload is invalid?
I am making a type erased class TypeErased using std::variant, that could be an integer, a complex number, a vector, or an error.
While I am making the addition operator (which uses std::visit), I ...
0
votes
3
answers
98
views
Can we call the respective original function with parameters automatically from proxy class in C++?
I have a class and a proxy class which holds pointer to original class to call its functions in C++. I am using proxy class for logging purpose . From each function of proxy class , In addition to ...
0
votes
0
answers
50
views
Best Practice for updating class attribute based on values
I have to read set of csv files which have 5 columns like name, age, address, type and distance. As these column names are string and I want to iterate them in my pandas df. I have created a class ...
0
votes
1
answer
21
views
How to Configure and Use My Existing WhatsApp Business Number with Twilio API?
I have successfully created a webhook and configured it to handle incoming messages and send responses using Twilio's API. However, I'm currently using a Twilio-provided WhatsApp Business number. I ...
-1
votes
1
answer
57
views
Need help designing a constexpr lookup [closed]
I am developing a library to run pipelines defined at compile time. This is done for some stricter compile-time checks and works fairly well in the scenarios tried so far. Now I want to add a new kind ...
0
votes
0
answers
44
views
What is the preferred / recommended rlang metaprogramming syntax to use on both sides of an assignment operator in the `dplyr::mutate()` function?
I have a question about an issue that's similar to this older question about the dplyr::filter() function, except that my example is a bit more complicated because dplyr::mutate() needs to process ...
-1
votes
2
answers
105
views
C++ extraneous 'template<>' in declaration of variable 'val'
I'm trying meta-programming so that factorial can be computed in compile-time. Here is the 1st version:
template <int N>
struct Fac {
static const int val = N * Fac<N - 1>::val;
};
...
0
votes
1
answer
74
views
How to dynamically create type annotations in Python?
Normally, one can define a class with some type-annotated fields as follows:
class A:
a: str
How to do this dynamically using type function?
I know the case when a is assigned to a value, i.e., ...
4
votes
1
answer
58
views
Behavior of object.__new__ Python dunder. What is happening under the hood?
I'm experimenting with metaprogramming in Python (CPython 3.10.13) and noticed some weird behavior with object.__new__ (well, weird to me, at least). Take a look at the following experiment (not ...
2
votes
1
answer
37
views
Wrapped functions of a Python module raise TypeError
I am currently trying to replace a module in a large code base in a certain condition and to figure out when any function of this module is called, I wrap each function/method in the module with a ...
0
votes
1
answer
97
views
How to use a non-template function to achieve perfect forwarding by an argument-wise manner?
template<typename T> class Group;
template<typename...U>
class Group<std::tuple<U...>> {
public:
typedef std::tuple<U...> type;
void emplace_back(U&......