metaprogramming Questions
5
Solved
is there any way to repeat a C code N times with a macro? Also N is a macro.
For example if I have this macros:
#define N 5
#define COODE "nop\n\t"
#define REPEAT [...]
When I call repeat the p...
Kirtley asked 17/11, 2014 at 22:57
2
Solved
I am studying concepts in C++ 20, and came up with the need of defining a concept using a previous defined concept.
So, in the example below I expected f<pub_b>() to generate a compiler error...
Stoltz asked 19/10, 2023 at 13:39
2
Solved
I have a function that takes an std::array of given size N
void func(std::array<int,3> x) {
// do something
}
int main() {
func({4,4,4}) // works
func({4}) // works as well
}
I understan...
Apotheosis asked 17/10, 2023 at 11:9
3
Solved
I just found out how to check if operator<< is provided for a type.
template<class T> T& lvalue_of_type();
template<class T> T rvalue_of_type();
template<class T>
stru...
Graybill asked 24/1, 2010 at 16:11
4
Solved
I was wondering if C++0x provides any built-in capabilities to check if a parameter pack of a variadic template contains a specific type. Today, boost:::mpl::contains can be used to accomplish this...
Underplot asked 22/1, 2010 at 16:4
1
Solved
I have this program:
class Foo {
has $.first;
}
my $a = Attribute.new(
:name('$!second'),
:type(Int),
:package('Foo'),
:has_accessor(True)
);
Foo.^add_attribute($a);
Foo.^compose;
Foo.^attr...
Parham asked 10/8, 2023 at 9:19
3
Solved
I wanted to move or assign a std::vector<Scalar> into a std::vector<float> depending on the type Scalar.
If Scalar is float then move, else copy.
I tried this code
#include <vector&g...
Jakie asked 7/8, 2023 at 13:3
3
Solved
I am in search of a ::std::function usable in constexpr.
Use case: I have a function which takes a function pointer as an argument, and a second which passes a lambda to the first function. Both ar...
Soggy asked 30/12, 2018 at 12:56
4
Solved
I want to have such a function that it's return type will be decided within the function(depending on the value of the parameter), but failed implementing it. (template specialization maybe?)
// h...
Levileviable asked 6/5, 2015 at 22:45
4
Solved
Perl provides an API via CORE::prototype, that allows you to get a prototype. This is further documented by Sub::Util which is the documented method for working with subs,
Sub::Util::prototype,
Re...
Caressa asked 10/9, 2020 at 19:27
2
This is kind of a weird and un-Swift-thonic question, so bear with me.
I want to do in Swift something like the same thing I'm currently doing in Objective-C/C++, so I'll start by describing that.
...
Dullish asked 26/12, 2015 at 4:26
4
Solved
It is possible to access a singleton class from a Ruby object with:
some_object.singleton_class
Is it possible to do the reverse operation : access the original object when inside the singleton ...
Tetra asked 5/2, 2019 at 9:32
2
Solved
I am coding using scala3, leveraging programmatic structural types.
The structural types happen to mimic existing case classes:
their definition is pure boiler plate,
hence the temptation to craft ...
Pernas asked 23/11, 2022 at 15:42
1
Solved
I am trying to create a polymorphic function that accepts only built-in vectors (as in @Vector) of length 4. From what I understand, the length of vectors are comptime known, and I would like to ad...
Brooke asked 7/4, 2023 at 10:3
1
how to generate a private parameterless constructor on a class (at compile time) when it annotated with @entity
annotation - in scala 3 macros
class entity extends scala.annotation.StaticAnnotation...
Scarabaeid asked 18/1, 2023 at 12:15
4
How can I get a map of the key/values of only the user-defined properties on one of my domain objects?
Problem is if I do this myself, I get my properties plus class, metaClass, constraints, closu...
Monagan asked 14/6, 2011 at 12:11
1
I started reading about reflection in C++20 and got quite confused. What is the current state of it, i.e. how much can we use as of now?
I've found reflection TS - but even the examples on this web...
Presidentelect asked 28/7, 2021 at 16:56
8
Solved
Can someone please tell me what the following snippet
obj.send("#{method_name}")
is and does?
Willemstad asked 26/7, 2010 at 17:22
1
I want to be able to create a python class like the following programmatically:
class Foo(BaseModel):
bar: str = "baz"
The following almost works:
Foo = type("Foo", (BaseModel...
Flit asked 18/2, 2023 at 13:41
7
Apologies if this question has already been raised and answered.
What I need to do is very simple in concept, but unfortunately I have not been able to find an answer for it online.
I need to crea...
Grope asked 1/11, 2012 at 19:38
2
Solved
I have the following code which is used to call a function on an object and pass any argument in a perfect-forwarding way
template <typename F, typename T>
inline auto call_with_args(F&&a...
Salpa asked 7/2, 2023 at 18:11
6
Solved
Pretty sure I know the answer to this already, but it's worth a shot.
So, say I have a typelist:
template <typename ...Ts>
struct typelist{};
That contains some objects:
struct foo{};
st...
Soilasoilage asked 7/9, 2015 at 18:23
7
There is function in python called eval that takes string input and evaluates it.
>>> x = 1
>>> print eval('x+1')
2
>>> print eval('12 + 32')
44
>>>
What is ...
Dekow asked 18/3, 2010 at 10:49
1
Solved
This is similar to this question for classes, except the same procedure does not seem to work for Grammars.
grammar TestGrammar {
token num { \d+ }
}
my $test-grammar = TestGrammar.new();
my $to...
Putsch asked 20/12, 2022 at 9:24
1
Solved
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 f...
Oleaceous asked 16/12, 2022 at 6:20
© 2022 - 2024 — McMap. All rights reserved.