The class template std::variant represents a type-safe union. An instance of std::variant at any given time either holds a value of one of its alternative types, or in the case of error - no value
Questions tagged [std-variant]
139 questions
0
votes
1 answer
How to make a map key to be of two different data types?
I have a std::unordered_map container, where Key can be of two data types:
64-bit unsigned int
tuple having (8-bit unsigned int, 8-bit unsigned int, 16-bit unsigned-int, 32-bit unsigned int)
But value is an object type that is the same with both…

bvb
- 633
- 2
- 7
- 15
-1
votes
2 answers
C++2017 Reference to std::vector
I try to store a reference to a std::vector consisting of std::variant.
I can create a const std::variant& to a element of a vector, but I struggle to store the reference to the whole vector. I guess that the answer is related to this post c++…

StephanH
- 463
- 4
- 12
-2
votes
2 answers
Select & build a compile-time tuple structure based on a runtime-provided mapping
I am working on a piece that requires some compile-time data structures to be created from a run-time provided mapping. If the runtime provided mapping matches the pre-defined compile-time pattern, the appropriate data structure should be created.…

user3641187
- 405
- 5
- 10
-3
votes
1 answer
unable to get the address of the element in the list by variant
I was trying to loop a list and getting the address of the element.
But all of the element's address is the same when using variant class.
int main()
{
std::list, std::list>> list_of_lists;
…

Jonathan Sum
- 76
- 2
- 7