variant Questions
2
Solved
The normal dynamic array supports empty (= nil, Length() = 0).
The variant array however does not seem to support this.
I pass my data in variant array (because of OLE/COM), and I get an error wh...
2
Solved
I have a situation where a function must return a value taken from a table. A cell in this table (let's assume the table just works...) may contain a value, or it might not. This value can also be ...
Perceval asked 18/5, 2017 at 16:13
2
Solved
I have two different objects:
struct TypeA {
std::size_t no;
std::string data;
std::string data2;
};
struct TypeB {
std::size_t no;
std::string data;
std::string data2;
std::string data3;
...
1
For some standard library classes, access to parts of their contents may legitimately fail. Usually you have the choice between some potentially throwing method an one that is marked noexcept. The ...
2
Solved
I'm playing with the C++17 std::variant type and tried to compile the cppreference example code for get():
#include <variant>
#include <string>
int main()
{
std::variant<int, floa...
Intramundane asked 26/9, 2018 at 15:30
1
Solved
Consider the following two programs:
#include<variant>
#include<iostream>
constexpr auto f() {
using T = std::variant<bool, int>;
T t(false);
t = T(true);
return std::get<...
1
Solved
Barry gave us this gorgeous get_index for variants:
template <typename> struct tag { };
template <typename T, typename V>
struct get_index;
template <typename T, typename... Ts>...
Chalcocite asked 6/12, 2018 at 12:35
1
Solved
I want to have a variant which may contain type Foo, (disjoint) type Bar, or nothing. Well, naturally, I was thinking of using std::variant<Foo, Bar, void> - but this doesn't seem to work. Th...
Carltoncarly asked 2/11, 2018 at 22:24
3
Solved
This answer describes how to stream a standalone std::variant. However, it doesn't seem to work when std::variant is stored in a std::unordered_map.
The following example:
#include <iostream&g...
2
Solved
Suppose I have a Shape base class and Circle, Line, and Point derived classes. I have two functions.
std::variant<Circle, Line, Point> process(const Shape &s);
Shape process(const Shape&...
Grackle asked 12/9, 2018 at 13:54
4
Trying to build something with Android Studio 3.0 that worked fine in a previous version. Now I am seeing:
Error:Execution failed for task ':mobile-app:transformClassesWithRetrolambdaForDevDebug'....
1
Solved
I have done some research and haven't found any similar question.
I have a VBA macro that imports a .CSV file containing telegrams sent by a device.
In the end of this macro, I want to create a g...
Exceptive asked 24/7, 2018 at 12:2
2
Solved
The types below are taken from this question
(* contains an error, later fixed by the OP *)
type _ task =
| Success : 'a -> 'a task
| Fail : 'a -> 'a task
| Binding : (('a task -> unit) -...
Equatorial asked 29/5, 2018 at 19:41
1
Solved
I can define a toy state machine (with trivial input) as follows:
--------------------------------------------
-- module State where
data State = A | B Int
--------------------------------------...
0
I have this piece of code that works really good in GCC7.2, clang 7 and MSVC, but not in GCC 8.0. Apparently, it deals with the copy constructor...
#include <iostream>
#include <variant&g...
3
Solved
I have a Delphi generic class that exposes a function with an argument of the generic type. Inside this function, I need to pass an instance of the generic type on to another object expecting a Var...
1
Solved
Here is simple example,
We can define a low level union like this :
static union
{
uint64_t a;
uint8_t b[8];
};
but we cannot declare std::variant like this(please do not care about syntax,cor...
Boonie asked 15/3, 2018 at 5:8
1
While using std::visit / std::variant I see in the profiler output that std::__detail::__variant::__gen_vtable_impl functions take the most time.
I did a test like this:
// 3 class families, all ...
Doubt asked 7/3, 2018 at 7:46
4
Solved
According to cppreference std::get for variant throws std::bad_variant_access if the type contained in the variant is not the expected one. This means that the standard library has to check on ever...
1
Solved
I have the following Variant:
Dim comboitems() As Variant
that I use in all the code as an array that contains the values of a ComboBox control.
In a certain point of the code, I need to clear/...
2
Solved
I was wondering if an implementation of std::variant must necessarily be "flat" or whether it is allowed to dynamically allocate memory for its members, such that a sequence of variants would degen...
Shriner asked 18/12, 2017 at 20:36
1
Solved
this is example inspired by example from cppreference
struct S {
operator int() { throw 42; }
};
int main(){
variant<float, int> v{12.f}; // OK
cout << std::boolalpha << v.v...
2
Solved
I have a std::variant that I'd like to convert to another std::variant that has a super-set of its types. Is there a way of doing it than that allows me to simply assign one to the other?
template...
Atonement asked 9/11, 2017 at 13:34
3
Solved
I'm trying to understand the example of std::visit from cppreference, Where I saw the following line of code:
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
te...
Karoline asked 6/10, 2017 at 11:43
3
Solved
Consider this code:
#include <variant>
struct x {
int y;
};
int main() {
std::variant<x> v(std::in_place_type<x>, {3}); /*1*/
return std::get<x>(v).y;
}
This does no...
Headsail asked 3/10, 2017 at 8:41
© 2022 - 2024 — McMap. All rights reserved.