metaprogramming Questions
3
Solved
As we all know, classes can't be inherited from fundamental types and from classes that are marked as final. But despite that, the code presented below compiles without any problems on Clang 12 and...
Kilocalorie asked 4/4, 2022 at 12:43
4
Solved
I'm trying to use Javascript Proxy objects to trap the arguments that are passed to a 'method' of the target that I'm proxying.
Please consider this example:
var test = {
doSomething: function()...
Sori asked 31/7, 2014 at 21:12
5
Solved
I am attempting to eval the following tab-indented string:
'''for index in range(10):
os.system("echo " + str(index) + "")
'''
I get, "There was an error: invalid syntax , line 1"
What is it c...
Belenbelesprit asked 2/10, 2012 at 20:44
4
Solved
I am having trouble understanding non-type template arguments and was hoping someone could shed light on this.
#include <iostream>
template<typename T, int a>
void f() {
if (a == 1) ...
Solander asked 23/4, 2015 at 4:59
2
Solved
Is there a type trait, or is it possible to write a type trait is_scoped_enum<T> such that:
if T is a scoped enumeration, is_scoped_enum<T>::value is true and
if T is any other type, ...
Laclair asked 23/5, 2012 at 17:15
2
Solved
Why can't we use compile-time 'variables' in consteval functions as template parameters?
I was testing this code (https://godbolt.org/z/fe6hhbeqW)...
// Returns the nth type in a parameter pack of types (ommited for clarity)
// template <std::size_t N, typename...Ts>
// nth_type{...
Dogtired asked 29/1, 2022 at 13:7
1
Solved
I know that it's way easier to ensure single instances from the class level, and that there's the excellent Staticish module from Jonathan Stowe that does the same by using roles, but I just want t...
Garbers asked 16/1, 2022 at 11:43
3
Solved
I have a ruby program, and I want to accept the user's made up method, and make a new method out of that name. I have tried this:
def method_missing(meth,*args,&block)
name = meth.to_s
class...
Jorry asked 10/11, 2011 at 5:12
1
Solved
Background:
I am building an editor extension for Unity (although this question is not strictly unity related). The user can select a binary operation from a dropdown and the operation is performed...
Fillmore asked 29/12, 2021 at 18:25
3
Solved
I have a pointer to the method:
struct A { int method() { return 0; } };
auto fn = &A::method;
I can get a return type by std::result_of, but how I can get from fn the class owner of the met...
Corazoncorban asked 11/2, 2017 at 11:26
1
Solved
The excellent 2011 Advent of Raku post Meta-programming: what, why and how provides a few clear examples of using EXPORTHOW to create a declarator that acts like class. Here's the first:
my class S...
Stays asked 13/12, 2021 at 16:49
1
Is there any way to programmatically tell if a given function in r has standard evaluation, and if not, which component of function evaluation –
parsing,
matching,
scoping,
promise formation,...
Koan asked 17/2, 2018 at 6:54
1
Solved
I have been stuck on this issue for a week and don't seem to be getting anywhere. I am trying to copy some methods and fields from one class to another.
I have two phases that are involved in this....
Planospore asked 21/10, 2021 at 5:21
9
#inherited is called right after the class Foo statement. I want something that'll run only after the end statement that closes the class declaration.
Here's some code to exemplify what I need:
c...
Educational asked 26/4, 2009 at 10:47
2
Solved
I've got a class, where a method should only run once. Of course, it could easily be done with artificial has_executed = True/False flag, but why use it, if you can just delete the method itself? p...
Deltadeltaic asked 18/10, 2021 at 14:43
4
Solved
I have created a complex computational model with lots of parameters. Since I need to run many scenarios, I have decided to wrap all those input parameters into one huge struct:
using Parameters
@w...
Shippee asked 17/4, 2021 at 13:35
5
Solved
I am aware of how to create getters and setters for properties whose names one already knows, by doing something like this:
// A trivial example:
function MyObject(val){
this.count = 0;
this.valu...
Hallvard asked 25/10, 2011 at 15:45
1
Solved
Raku's state declarator can be used to give a subroutine or other block its own local state that persists across multiple invocations of the function:
sub f { state $n++ }
say f; # OUTPUT: «0»
say ...
Jacelynjacenta asked 5/10, 2021 at 18:5
1
Solved
I need to implement a testing function which checks compile-time error information for the "splain" plugin, part of this function needs to convert a codeblock into a string, e.g.:
def con...
Bowsprit asked 2/10, 2021 at 0:4
4
Solved
I'm trying to explicitly use LambdaMetafactory.metafactory, I can't understand why it works only with the Runnable functional interface. For Example, this code does what it is expected (it prints &...
Walli asked 6/11, 2014 at 9:20
1
Solved
I'm porting a macro from Scala 2 to Scala 3. As part of it's work, the Scala 2 macro creates an instance of a generic type using the default constructor. This is simple to do with a quasiquote in S...
Peirsen asked 28/5, 2021 at 12:26
3
Solved
At compile time in C++11 in a template function that takes 2 template parameters, both of which must be unsigned integer types, I'd like to have a local variable have the type of whichever of the t...
Spanjian asked 25/9, 2012 at 3:40
3
In my program I have some code which looks something like this: A collection of functions or classes which uniquely implement a common template via template specialization:
constexpr int NUM_SPECIA...
Eluvium asked 18/8, 2021 at 11:53
4
Solved
I have a mixin for which I would like to get a list of all the classes that have included it. In the mixin module, I did the following:
module MyModule
def self.included(base)
@classes ||= []
@...
Ally asked 12/10, 2010 at 18:36
1
Solved
I know that a lambda object is not a std::function object, so I understand that this would not work:
template <typename ...args_t>
void func(std::function<void(args_t...)> function_, a...
Violet asked 6/8, 2021 at 2:36
© 2022 - 2024 — McMap. All rights reserved.