Skip to main content
Advice
0 votes
8 replies
381 views

I'm looking for a way to store type "dynamicly" in a using (or concret implementation) that would be modifable and accessible at compile-time. I would like something like: struct ...
DipStax's user avatar
  • 572
11 votes
4 answers
1k views

The program test tag dispatching pattern, where the function process_data(tag, a, b) can accept 2 tags int_tag, float_tag. There are 3 case: int_tag and a, b are int -> print a + b float_tag and a,...
Huy Le's user avatar
  • 2,009
4 votes
2 answers
541 views

Consider the following struct: struct Particle { float scale; float opacity; float rotation; }; I want the following to compile: static_assert(indexOf<&Particle::scale>() == 0); ...
Vittorio Romeo's user avatar
526 votes
21 answers
845k views

Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this: >>> class Foo: ... bar = 'hello' ... baz = 'world' ... ...
Julio César's user avatar
  • 13.4k
2 votes
1 answer
165 views

I have a class Foo from a third party library that has a lots of setters with a string argument named as set_parameter_name(std::string value). And I need to configure an instance of the class using a ...
Grigory's user avatar
  • 33
1 vote
0 answers
98 views

I'm trying to construct a typed lambda calculus, something along the lines of: struct Fun<T>(T); // actual definition elided for simplicity struct TypeErasedExpr { /* elided for simplicity */ } ...
terepy's user avatar
  • 89
-1 votes
1 answer
205 views

Here is code: aml::type_list<int,int,char,std::string> example; std::tuple_element_t<2,std::tuple<decltype(example)>> a = 'b'; But when i try to run code it says, static assertion ...
Hazret Hasanov's user avatar
9 votes
3 answers
973 views

In the snippet below, base_type_t has 2 template arguments; T1 and k1. The templates foo_t, bar_t, and baz_t derive from this base, using the derived template's parameter for T1, but providing a ...
jordi's user avatar
  • 195
-1 votes
1 answer
142 views

In c++ when i try to write a code that returns reverse of a type list what i wrote( a user defined template class): template <typename ...V,typename ...D> constexpr decltype(auto) merge(...
Hazret Hasanov's user avatar
8 votes
1 answer
199 views

I've created a type trait to create a type pack of rotating index sequences: #include <cstddef> #include <utility> template <class...> struct type_pack {}; template <size_t N>...
Ted Lyngmo's user avatar
  • 125k
0 votes
1 answer
250 views

I’ve been experimenting in order to deepen my understanding of Python metaprogramming, and I have noticed a potentially useful behavior that I cannot find documentation to explain, so I don’t know ...
Steve Jorgensen's user avatar
2 votes
2 answers
242 views

I have this data class: @dataclass class User: id: str name: str pwd: str picture: str url: str age: int # many, many more attributes Now, I have to make all of the ...
Aadvik's user avatar
  • 1,522
7 votes
1 answer
226 views

I am trying to do some monkey patch work on an existing third-party library I am using. Summary This sequence does not work: Monkey patch A.__new__ using mynew Monkey patch A.__new__ again using ...
Gerges's user avatar
  • 6,679
0 votes
1 answer
58 views

I want to parse and calculate formulas line by line. The formulas depend on the given variables x1 and x2. The number of formulas per line is not fixed, and there are dependencies between the results ...
HuaXian Tan's user avatar
1 vote
1 answer
271 views

To better understand C++26's reflection, I would like to understand how we can reflect on the name of a struct to inject it in another one (potentially replacing its body, just keeping the name) For ...
Vincent's user avatar
  • 61.2k

15 30 50 per page
1
2 3 4 5
324