25,326 questions
2
votes
2
answers
115
views
C++ reflection - compile time index access - but not with a macro
Using C++26 reflection, the following works nicely:
template<size_t from, size_t to, typename F>
void compile_time_index_access(size_t index, F&& f) {
template for(constexpr size_t i : ...
Advice
1
vote
3
replies
57
views
Compile time index access using C++26 reflection
The question has moved to be a Q&A post following the comments:
C++ reflection - compile time index access - but not with a macro
1
vote
1
answer
147
views
How to add a string literal annotation to items?
I am experimenting with the new annotation freshly added in C++26, specifically looking at the examples provided in the proposal paper.
The paper contains the following example using a hypothetical ...
Tooling
0
votes
3
replies
70
views
How would I preform a selective deep copy in Java?
I want to deep copy specific fields from one class to another. However, I don't want to copy everything. Is there a tool for this or another method I could use? The class is in a library, so I can't ...
1
vote
2
answers
64
views
Exception when loading F# types that implement an interface which uses generics from an assembly
I'm trying to load a type from an assembly at runtime that implements this interface which is in a project called PluginBase:
type IPlugin =
abstract member TestString: Option<string> with ...
2
votes
1
answer
135
views
How can I determine if the memory at a certain address was allocated by / is managed by CUDA?
Suppose I get a pointer, and I want to determine whether it's "CUDA-associated", i.e. allocated by CUDA as pinned host-side memory, device-side memory, managed memory, array memory, etc. - ...
2
votes
0
answers
111
views
Using MethodRental's SwapMethodBody on powershell classes
I recently discovered MethodRental and it seems really interesting, coming from JS, being able to pre-empt existing functions can be a neat hacky get-out-of-jail card for the toolbelt.
As an aside, ...
Tooling
0
votes
4
replies
78
views
What are references, instruction and examples for the simplest way of building clang from this LLVM project on Windows?
I want to compile github branch https://github.com/bloomberg/clang-p2996 (forked off of llvm/llvm-project) to try out some of the experimental reflection features.
Following https://llvm.org/docs/...
Best practices
0
votes
2
replies
73
views
Quarkus native compilation requires explicit declaration of Classes to be registered for Reflection
I'm using Quarkus enabling native compilation. At runtime I noticed some exceptions that required me to register classes for reflection e.g:
@RegisterForReflection(
targets = { MyClass.class, ...
Best practices
0
votes
2
replies
57
views
Avoiding duplicated Spring Bean classes that just have different field-level `@Value` annotations
Suppose that I have two classes that differ only in terms of their @Value "values" on their fields. For example:
@Component
public class BlueWidget {
@Value("${blue.message}")
...
-1
votes
2
answers
109
views
ArgumentException when calling MethodInfo.MakeGenericMethod [closed]
public void Test<T>(T reference, T same, T differentOrGreater)
{
var comparisonInterface = typeof(T)
.GetInterfaces()
.FirstOrDefault(
i => i.IsGenericType &...
2
votes
1
answer
110
views
Cannot use Format on reflected object's property ToString
I can format an Int32, I1, as currency - it displays:
I1 = $31,742.
But I cannot format an Int32 property of a class whose PropertyInfo and whose value and whose format is determined by reflection. ...
1
vote
1
answer
110
views
Get all implementations of an interface for a class, including for base
public interface A<out T>
{
public T Property { get; }
}
public class BaseClass : A<string>, A<int>
{
string A<string>.Property => "BaseClass";
int A&...
11
votes
1
answer
1k
views
Is there any way to iterate data members with STL algorithms using the C++26 reflection?
With C++26 reflection, we can simply iterate all data members of an object:
#include <iostream>
#include <meta>
struct Foo {
int x;
int y;
};
void PrintFoo(const Foo& foo) {
...
Advice
0
votes
5
replies
127
views
Reflection access to static extension methods and extension properties
With the new C# 14 feature of static extension methods and extension properties, how to find and use them via reflection?
(From the docs)
public static class MyExtensions
{
extension(string str)
...