metaprogramming Questions

2

Solved

I'm able to run the following code just fine and it provides the expected result: julia> using DataFrames, DataFramesMeta julia> expr = "2*:a+:b" "2*:a+:b" julia> df ...
Edik asked 9/12, 2022 at 1:7

11

Solved

For the purpose of introspection, sometimes I've wanted to automatically assign serial numbers to types, or something similar. Unfortunately, template metaprogramming is essentially a functional la...
Ahrens asked 29/5, 2011 at 6:50

2

Solved

Does std::remove_cvref replace std::decay after C++20? From this link, I cannot understand what this means: C++20 will have a new trait std::remove_cvref that doesn't have undesirable effect of st...
Rhodie asked 30/10, 2022 at 23:46

5

Is there a way in C++ to determine function signature of a callable object? Consider following: template< typename F > void fun(F f) { // ... } Lets assume that fun is called only with c...
Newcomen asked 9/5, 2011 at 13:23

1

Solved

{rlang} has this unexported function that can be used to capture the ellipsis arguments (names, expressions, and env). It powers the magic of rlang::enquos(). f <- function(...) rlang:::captureD...
Manslaughter asked 18/10, 2022 at 10:51

7

Solved

I am trying to use template meta-programming to determine the base class. Is there a way to get the base class automatically without explicitly specializing for each derived class? class foo { pub...
Lorsung asked 3/1, 2012 at 7:54

1

i am writing a macro to get annotations from a 'Class' inline def getAnnotations(clazz: Class[?]): Seq[Any] = ${ getAnnotationsImpl('clazz) } def getAnnotationsImpl(expr: Expr[Class[?]])(using Quot...
Gyrfalcon asked 8/3, 2022 at 4:41

1

Solved

The following answer addresses how to safely extract property names from a type. What this answer accomplishes is that, indeed, if there is a mistyping you get a compile-time error, not a runtime e...
Predestination asked 16/9, 2022 at 8:45

0

I want to define my own C++-17-like if statement. (It's an exercise in metaprogramming.) I easily could define: inline def xif[T](inline cond: Boolean)(inline body: T) = if cond then body and/or d...
Furfuran asked 8/9, 2022 at 22:58

4

Solved

(A toy, minimal not-working example) The next code won't compile with cpp20/17: template<typename TSomeTemplate> struct A { static constexpr size_t B = 1; template<typename T, typename....
Rabelais asked 29/7, 2022 at 12:38

6

Solved

How does one filter duplicate types from a tuple? For example: using Tuple = std::tuple<int, double, int, double, std::string, std::string> using FilteredTuple = without_duplicates<Tuple...
Pee asked 1/5, 2019 at 19:57

3

Solved

I want to create a class specialization that has the same implementation if it gets passed any std::variant or any boost::variant. I tried to play around with std::enable_if, std::disjunction and s...
Roxanneroxburgh asked 8/7, 2022 at 11:38

1

Solved

Why and when does the compiler optimize away static member variables? I have the following code #include <iostream> #include <typeinfo> class X { public: X(const char* s) { std::cout ...

4

Solved

What is Python's equivalent of Ruby's method_missing method? I tried using __getattr__ but this hook applies to fields too. I only want to intercept the method invocations. What is the Python way t...
Clemence asked 15/7, 2011 at 8:3

3

Solved

I am trying to dynamically create module level functions from the methods in a class. So for every method in a class, I want to create a function with the same name which creates an instance of the...
Cowey asked 8/9, 2010 at 2:45

1

Solved

Let's first introduce a helper type that represents a parameter pack: template<typename... T> struct Pack { }; Now, here's the function with the weird behaviour: template<typename... TT, ...
Alphabetic asked 13/6, 2022 at 12:5

2

Solved

What I would like to do is to create: template<Args... args)> int println(Args...) { // implementation which calls: // printf("<string literal format string at compile time>", args.....
Satanism asked 10/6, 2014 at 22:44

4

Solved

I'm looking for a way to get an object property name with typechecking that allows to catch possible regressions after refactoring. Here's an example: the component where I have to pass the prope...
Rational asked 5/11, 2015 at 14:48

6

Solved

I am working on an application with a message based / asynchronous agent-like architecture. There will be a few dozen distinct message types, each represented by C++ types. class message_a { long...
Rebuke asked 27/7, 2011 at 12:52

2

Solved

I have a program which depends on the result of std::is_same_v <const value_t, decltype(value)>. However, I have found that when functions are passed to this expression the result is un...
Gin asked 8/5, 2022 at 18:43

1

Solved

I have an enum : from enum import Enum class MyEnum(Enum): val1 = "val1" val2 = "val2" val3 = "val3" I would like to validate a pydantic field based on that enum....
Nahama asked 30/4, 2022 at 19:13

0

This question is formulated in Scala 3/Dotty but should be generalised to any language NOT in MetaML family. The Scala 3 macro tutorial: https://docs.scala-lang.org/scala3/reference/metaprogramming...
Twice asked 14/4, 2022 at 18:57

4

Solved

I am a little bit confused about the object and type classes in Python 3. Maybe someone can clear up my confusion or provide some additional information. My current understanding is that every cla...
Mirabel asked 20/4, 2019 at 15:57

0

Suppose we have a current class: template<typename T> struct Inheriter : public T {}; Note that its instantiation would be well-formed only if T is a class/struct that is not declared as fin...

2

How to specialize a template function for the case that the value of one of its argument is known/unknown during compile time (before actually compile and run the program)? I can't figure out how ...
Acidosis asked 28/9, 2016 at 9:11

© 2022 - 2024 — McMap. All rights reserved.