I want to define a std::variant that can store a vector of pairs, with strings and Values. I want to create a structure like below: How can I do i ...
I want to define a std::variant that can store a vector of pairs, with strings and Values. I want to create a structure like below: How can I do i ...
Here's a sample code: http://coliru.stacked-crooked.com/a/5f630d2d65cd983e #include <variant> #include <functional> template<class... ...
In Swift you can have an enum type with associated values. enum Thing { case num(Int) case two(String, Double) case other } var t: Thing = . ...
I am looking at using std::variant to store basic types such as float, int, float2, float2, bool2, bool4, etc. which is rather trivial, but I would al ...
I'm trying to pass values to a function accepting a std::variant. I noticed I can use a function accepting a const reference to a variant value, but n ...
I've got code that can be simplified to Obviously this can go throw if foo() returns the wrong variants, but that's not my problem here. (The real ...
Consider the following class template, that can hold either a value of type T or an instance of some ErrorInfo class, using a std::variant data member ...
I have some std::variant classes, each with several alternatives, and I would like to define a visitor class template that takes a variant as its temp ...
I am using C++17's std::visit() function on a variant with many alternatives, and the error messages produced by the compiler whenever I forget one or ...
I'm trying to implement an ad-hoc light weight state machine using std::variant. However, it seems that the variant fsm isn't declared right as it fai ...
I have a set of Writer classes each with a different implementation. I have a list of writers that offers the same interface. Calling a method on the ...
I'm trying to create a type capable of accepting a callable object of any type and wrapping one of its member functions (in this case, operator()) to ...
I am trying to visit a variant containing several classes. One of them does not have a specific field value but I handle it with constexpr, however, t ...
I'd like to create a hierarchy of visitors to handle instances of std::variant. I'd like to override some of the methods in subclasses for more specia ...
The following code #include <optional> #include <string> #include <variant> constexpr bool USE_VARIANT = 1; using T = std::condit ...
I would like to be able to create a variant that contains a std::map<std::string, MyVariant> as one of its cases. The ideal would be able to wri ...
Say you have entities in a 2D game framework or something similar -- e.g. a GUI framework -- where there are various types of entities that share comm ...
I am continually getting the following error message telling me that I am using a deleted function, which I think is the std::variant default construc ...
I am using std::variant and std::visit to call operator functions. I have a lot of variants (which mostly inherit from one superclass), but most of th ...
I want to increment / decrement a std::variant's type alternative, essentially like so: The problem here is that while emplace expects what clang's ...