close
Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
Filter by
Sorted by
Tagged with
Filter by Employee ID
Score of 1
1 answer
181 views

I'm trying to compile the following code: #include <stdio.h> #include <variant> int main() { enum class TokenType { FOO, BAR, }; using ConstTokenValue =...
Score of 10
0 answers
432 views

Coming from C++17 and trying to integrate operator<=>. I've stumbled on a conundrum. There seems to be no way to implement a generic container-like class where its T is a mutually recursive std:...
Advice
0 votes
9 replies
203 views

Is it possible to map the enum values to underlaying data types to use them with std::variant? I want to do something like the example below, but want the std::variant to understand it is an int or ...
Score of 0
2 answers
194 views

I'm trying to use code as below, but I am getting compilation errors. The goal here is to have the "unsupported type in visitor triggered at compile time when a D is passed to visitor. Can ...
Score of 0
0 answers
93 views

I have different enums to specify the type of an object. I then use std::variant as an entity can be of any type, i.e. enum Type1{ type1a, type1b }; enum Type2{ type2a, type2b }; ...
Score of 2
2 answers
171 views

I have the following code that does not compile with Qt 6.7.2 on Debian : #include <QCoreApplication> #include <iostream> #include <variant> class Foo : public QObject { ...
Score of 2
2 answers
195 views

How to implement a class that dynamically switching types using std::variant in runtime? I'm currently trying to create a class that can: Store a value in a std::variant with configurable type ...
Score of 1
2 answers
155 views

I am at a very early stage in writing a C++ program replicating the most basic functions of the ls bash command. I use the <filesystem> header. The std::filesystem::directory_iterator and std::...
Score of 1
1 answer
122 views

It's possible to store ints or floats in the same memory location using std::bit_cast (including ints larger than 2^24 i.e. they can't be stored as whole numbers in floats because the mantissa has too ...
Score of 1
2 answers
155 views

I'm struggling with an odd behavior of the below code. The problem is that output of this snippet is "double". But we have an int in lhs. I dug for a while and figured out the compiler put a ...
Score of 1
1 answer
105 views

for this simple code #include <vector> #include <variant> #include <stdint.h> using KFPGAData = std::variant<uint16_t>; int main(int,char**) { int v = 10; KFPGAData d =...
Score of 1
2 answers
129 views

I want to store several different callable objects (different types) in a container (e.g. std::array) in order to invoke them later. Each callable has the same return type and the same amount and type ...
Score of 2
2 answers
380 views

I have a std::variant of possibly repeated types, and I would like to increment the active index of the variant. Here is an example demonstrating what I would like to do: template <typename... Ts&...
Score of 10
3 answers
5480 views

Let's say I am writing a class that passes a std::variant<A,B> to another class. While I design the class, I decide I'd like to keep a copy of the last thing that was passed to that other class. ...
Score of 0
1 answer
124 views

I see this piece of code for implementing a C++ std::variant-like type. This class is used as the variant storage. What does the buffer array stores? alignas(Types...) unsigned char buffer[sizeof(...

15 30 50 per page
1
2 3 4 5
13