metaprogramming Questions
10
Solved
I want to get into more template meta-programming. I know that SFINAE stands for "substitution failure is not an error." But can someone show me a good use for SFINAE?
Miche asked 11/6, 2009 at 18:25
2
Solved
I'm currently looking into using C++ (C++17) variadic templates for generating efficient, real-time simulations of circuits.
My goal is to leverage variadic templates to define a tree that can be t...
Demarcate asked 24/6, 2021 at 12:26
7
I would like something like that:
makeActiveBinding("f", function() {
called_as_a_function <- ... # <- insert answer here
if(called_as_a_function) {
sqrt
} else {
1
}
}, .Glo...
Aeriel asked 22/6, 2021 at 20:20
1
Solved
I am building something like an ActiveRecord class for documents stored in MongoDB (akin to Mongoose). I have two goals:
Intercept all property setters on a document using a Proxy, and automatical...
Exterminatory asked 8/4, 2021 at 11:11
1
Solved
The will trait gives compile-time access to the Variable on which it's called. Are there other ways to access the Variables that will be installed in a given lexical scope? (I know I can access the...
Nephralgia asked 10/5, 2021 at 11:46
2
Solved
I have a dictionary of function arguments that I want to pass to a function. For example:
function test_function(foo::Int, bar::String)
#...
end
params = Dict(
"foo" => 1,
"ba...
Doykos asked 7/5, 2021 at 2:1
7
Solved
Background
Consider the following:
template <unsigned N>
struct Fibonacci
{
enum
{
value = Fibonacci<N-1>::value + Fibonacci<N-2>::value
};
};
template <>
struct Fibona...
Krummhorn asked 25/5, 2009 at 22:24
14
Solved
One can define a static array at compile time as follows:
const std::size_t size = 5;
unsigned int list[size] = { 1, 2, 3, 4, 5 };
Question 1 - Is it possible by using various kinds of metaprog...
Diamagnet asked 4/6, 2010 at 22:44
4
The following code tried to replace an existing method in a Groovy class:
class A {
void abc() {
println "original"
}
}
x= new A()
x.abc()
A.metaClass.abc={-> println "new" }
x.abc()
A.met...
Bunkum asked 15/3, 2010 at 3:21
2
Solved
Is it possible to generate a new class with macro in Dotty, Scala 3 ?
Zlaja
Glycoside asked 24/12, 2019 at 21:26
2
Solved
How would I go about deriving the function
getField :: (Generic a, HasDatatypeInfo a) => Proxy (name :: Symbol) -> a -> b
to project a field from an arbitrary record using a type-level st...
Bourges asked 7/4, 2021 at 18:41
3
Solved
def method
a = 3
b = 4
some_method_that_gives # [a, b]
end
Saad asked 20/12, 2010 at 6:10
3
Solved
I have a module MyModule. I dynamically load classes into it. How can I get a list of the classes defined within its namespace?
Example:
def load_plugins
Dir.glob(File.dirname(__FILE__) + '/plug...
Transmissible asked 7/5, 2009 at 6:18
12
Solved
I have read in few different places that using C++11's new string literals it might be possible to compute a string's hash at compile time. However, no one seems to be ready to come out and say tha...
Harebell asked 21/1, 2010 at 18:8
8
Solved
I was reading an article on TheServerSide on ployglot programming on the Java platform. Some comments in the article refer to metaprogramming as the ability to generate code (perhaps on the fly).
...
Vincent asked 5/2, 2009 at 5:5
4
Solved
Background
I wish to use a meta class in order to add helper methods based on the original class. If the method I wish to add uses self.__attributeName I get an AttributeError (because of name man...
Pouncey asked 22/5, 2017 at 13:46
4
Solved
Is it possible to extend or modify the code of a C# class at runtime?
My question specifically revolves around Monkey Patching / Duck Punching or Meta Object Programming (MOP), as it happens in sc...
Lochner asked 27/12, 2010 at 10:20
3
Solved
I am interested in how you can generate an array of prime numbers at compile time (I believe that the only way is using metaprogramming (in C++, not sure how this works in other languages)).
Quick ...
Croton asked 17/2, 2021 at 10:4
9
Solved
One of the issues I have had in porting some stuff from Solaris to Linux is that the Solaris compiler expands the macro __FILE__ during preprocessing to the file name (e.g. MyFile.cpp) whereas gcc ...
Salerno asked 10/11, 2009 at 8:19
4
Solved
When developing C++ code, I often find myself trying to do something for all the data members belonging to a class. Classic examples are in the copy constructor and assignment operator. Another pla...
Municipal asked 5/2, 2021 at 2:11
4
Solved
A claim that I recall being repeated in the Clojure for Lisp Programmers videos is that a great weakness of the earlier Lisps, particularly Common Lisp, is that too much is married to the lis...
Forsyth asked 18/1, 2021 at 20:24
2
Solved
Given x = C.f after:
class C:
def f(self):
pass
What do I call on x that will return C?
The best I could do is execing a parsed portion of x.__qualname__, which is ugly:
exec('d = ' + ".".jo...
Tragedienne asked 18/9, 2014 at 20:6
8
template < unsigned int i >
struct t {
static const char *s;
};
template < unsigned int i >
const char* t<i>::s = ...;
where ... is "0 1 2 ... i-1", for example "0 1 2 3 4" for...
Grandaunt asked 4/11, 2010 at 11:21
1
Solved
I would like to use typeclass constraints in my Typed Template Haskell snippets, but just can't get them to work: the instances seem to be missing inside the splice.
Here is a standalone, minimized...
Packer asked 22/12, 2020 at 3:38
2
Solved
I'm trying to perform the equivalent of the eval method from Python in nim.
I was under the impression that parseStmt from the macros package should help me with this, but I'm facing a compilation ...
Guilbert asked 18/12, 2020 at 8:55
© 2022 - 2024 — McMap. All rights reserved.