metaprogramming Questions
4
While iterating through an array (or any other enumerable), is there any clean and simple way to know if you're on the final iteration?
For example, in a Rails view you might have a collection of ...
Hobnailed asked 1/1, 2020 at 22:14
1
I'm learning about template metaprogramming, and recently, I saw a talk on the CPPConference about void_t. Soon after that, I found out about the detection idiom.
However, I still have a hard time...
Godless asked 10/12, 2019 at 22:55
4
Solved
Problem description
Sys.setenv does not have an easy interface to supply LHS (the env var name) as a parameter. If one wants to dynamically define what env var should be set, then metaprogramming ...
Badger asked 6/12, 2019 at 3:13
1
Solved
I have a large codebase, which consists of thousands of functions.
I want to enable code execution before and after every function call, when the functions starts and when it ends.
Is there a way...
Bibb asked 28/11, 2019 at 12:14
1
Solved
C++20 introduces std::common_reference. What is its purpose? Can someone give an example of using it?
Dissentient asked 23/11, 2019 at 19:23
2
Solved
What is the point of defining respond_to_missing? as opposed to defining respond_to?? What goes wrong if you redefine respond_to? for some class?
Bank asked 9/12, 2012 at 23:37
4
I have an instance variable @foo and I want to write some code so that I get string 'foo'
any hint?
Putnam asked 28/12, 2012 at 19:20
2
Solved
If I want to check whether a method with a given name is defined, which is better to use, respond_to?, or defined??
From the point of view of efficiency, there can be an argument for using defined...
Helico asked 22/5, 2017 at 7:55
5
Solved
Consider the following code:
>>> class A(object):
... pass
...
>>> def __repr__(self):
... return "A"
...
>>> from types import MethodType
>>> a = A()
...
Crossindex asked 29/4, 2012 at 22:36
2
Solved
I have a comma-separated list of fields represented by a char array at compile time:
constexpr static char arrayStr[] = "a,b,c";
I would like to split on "," and have the number of elements avail...
Proclitic asked 30/9, 2019 at 22:3
8
Solved
In Ruby I think you can call a method that hasn't been defined and yet capture the name of the method called and do processing of this method at runtime.
Can Javascript do the same kind of thing ?...
Esta asked 19/3, 2012 at 23:50
2
Solved
How can I know if I actually need to return an l-value when using FALLBACK?
I'm using return-rw but I'd like to only use return where possible. I want to track if I've actually modified %!attrs or...
Negotiate asked 24/9, 2019 at 1:5
1
Solved
How can I add an attribute to a class dynamically? I tried this but it's complaining about a missing method and I'm not sure why since I'm not trying to add a method.
use v6.d;
class Foo does Met...
Shortsighted asked 18/9, 2019 at 12:47
1
Solved
In some rare cases where this would actually be acceptable, like in unit tests, you may want to get or set the value of a private attribute, or call a private method of a type where it shouldn't be...
Whitelivered asked 17/9, 2019 at 22:53
2
I have a templated class SafeInt<T> (By Microsoft).
This class in theory can be used in place of a POD integer type and can detect any integer overflows during arithmetic operations.
For ...
Tropopause asked 30/4, 2016 at 8:25
11
Solved
I find it very hard to figure out what is wrong with my code when using C++ template meta-programming. It might be that I am just not very good at understanding the error messages, but as far...
Empire asked 18/2, 2009 at 23:59
2
Solved
I am looking for a way to dynamically create classes with specific properties accessible via typical instance notation.
DynoOne = createClass('DynoOne',props=['A','B'])
d = DynoOne (database='XY...
Sand asked 5/9, 2019 at 18:23
2
Solved
I am trying to get a class decorator working. The decorator will add a __init_subclass__ method to the class it is applied to.
However, when the method is added to the class dynamically, the first...
Hausner asked 2/5, 2018 at 14:34
3
Solved
I'd like to implement annotation processor that will generate new class based on existing "prototype" class.
import java.util.List
@MyAnnotation
class MySuperClassPrototype {
static MySuperClass...
Doorn asked 5/12, 2011 at 15:17
2
Normally in Perl 6, only roles are allowed to be parametric. Here, we'll be attempting to make classes, a kind (referred to from here on out as a metaobject) that isn't normally allowed to be param...
Replica asked 19/8, 2019 at 10:12
0
I'm writing a library for creating monads in Perl 6. Since using just regular parametric roles makes it impossible to extend monads properly (to the best of my knowledge), I decided to create a cus...
Teletypewriter asked 3/8, 2019 at 16:53
0
Clang complains about trailing parameter pack is not defaulted but as far as i know it is in standard and possible. Am i doing wrong or is it a bug of clang ?
It is my in repo, if you want to look...
Similar asked 1/8, 2019 at 12:28
1
Solved
I have a C++ program where I've used template metaprogramming to generate small binary-format packets to be sent "over the wire", which gives better safety and clarity than a more naive approach of...
Coign asked 30/7, 2019 at 10:38
4
Solved
I would like to allow use of the class I'm writing to specify as a template parameters a list of types along with a list of allocators of those types in a manner that types are at odd positions and...
Boothe asked 25/6, 2011 at 3:5
2
Solved
I need some code to check whether a certain template is part of a parameter pack. To implement the check for normal classes, I use the multiple-inheritance based approach outlined e.g. by Louis Dio...
Plumber asked 19/6, 2019 at 10:52
© 2022 - 2024 — McMap. All rights reserved.