variant Questions

0

Consider following code: #include <variant> class A {}; class B {}; template<typename... Ts, typename Variant> bool constexpr is_of(const Variant& variant) { return std::visit( ...
Griner asked 23/8 at 15:23

17

i am new to android development, i started developing from scratch on a project i bought online, following the documentation, i encountered a error saying No variants found for 'app'. Check build f...

2

Solved

Please explain what is the difference between union and std::variant and why std::variant was introduced into the standard? In what situations should we use std::variant over the old-school union? ...
Flipflop asked 7/2, 2017 at 5:23

6

Solved

Dim Result() As Variant In my watch window, this appears as Expression | Value | Type Result | | Variant/Variant() How do I check the following: if Result is nothing then or if Result ...
Installment asked 30/3, 2011 at 0:43

3

Algebraic data types are a way to accurately describe the data. When it comes to JSON there is no problem with product types, that is each structure is listing props one-by-one that belong to them....
Adinaadine asked 3/3, 2014 at 18:5

2

Solved

Inventing a discriminated union/tagged variant I conclude that there is particular need in such a feature as "make destructor trivial on some conditions at compile time". I mean some kind of SFINAE...
Midgut asked 17/6, 2015 at 5:9

1

If an object-array is declared as a Variant type (in order to easily check whether it is initialized using the IsEmpty function) then, if the subsequently defined array's elements are referenced as...
Wein asked 3/8, 2022 at 21:0

5

Solved

I wish to model a value which can have two possible forms: absent, or a string. The natural way to do this is with Maybe String, or Optional<String>, or string option, etc. However, Go does ...
Washy asked 9/6, 2015 at 12:10

1

Solved

In std::holds_alternative and std::get_if documentation, it does not say what's the complexity requirements of the operations. Are the two functions always O(1), or it's linear in terms of number o...
Egret asked 23/12, 2022 at 7:44

2

Solved

I use boost::variant a lot and am quite familiar with it. boost::variant does not restrict the bounded types in any way, in particular, they may be references: #include <boost/variant.hpp> #...
Frosting asked 16/1, 2019 at 13:53

3

Solved

I have a class called foo_t that has a member called bar which could be any one of the types std::string, int, std::vector<double>, etc. I would like to be able to ask foo_t which type bar ha...
Dobb asked 25/2, 2018 at 21:24

2

The way std::variant dispatches to different visitor methods when std::visit is called is pretty reasonable when the variant alternatives are completely different types. Essentially a visitor-speci...
Ossetia asked 20/11, 2017 at 0:29

3

Solved

I want to create a class specialization that has the same implementation if it gets passed any std::variant or any boost::variant. I tried to play around with std::enable_if, std::disjunction and s...
Roxanneroxburgh asked 8/7, 2022 at 11:38

3

Solved

I want to execute an overloaded function over a variant. The following code block works and compiles, but the visit invocation seems overly complex. Why can I not simply write: std::visit(&f, s...
Applicant asked 6/4, 2021 at 0:48

2

I'd like to customize VSCode colour settings in general for dark or light theme variants, for example: "workbench.colorCustomizations": { "light": { "editor.background&qu...
Sailesh asked 13/10, 2020 at 7:11

2

Solved

How can I use use something like variant (which is in C++) in Julia? In C++, I can do something like this variant<int, float> value; How can I do the same thing in Julia for a parameter of a...
Peterus asked 4/1, 2022 at 20:25

1

Solved

I have figured out that std::visit can be used the following way: std::visit([](auto&& arg) { using T = std::decay_t<decltype(arg)>; if constexpr (std::is_same_v<T, int>) st...
Khajeh asked 11/12, 2021 at 12:10

3

Solved

I'm trying to communicate with an OPC DA server and need to write in a tag which is in an array format. We can connect with a simulation server, read tags (int, real, array) and write tags (int, re...
Pentheas asked 25/11, 2021 at 23:1

1

Solved

Looking at the following code: type z = Z of z type 'a s = Z | S of 'a type _ t = Z : z t | S : 'n t -> 'n s t the last line contains a generic variant, or what seems like one, but instead of...
Botulism asked 22/10, 2021 at 22:32

1

Solved

Here is my code which compiles fine for clang but failed with gcc #include <iostream> #include <string> #include <regex> #include <variant> struct Id { void SetValue(const...
Fluorosis asked 19/7, 2021 at 13:21

3

Solved

In an answer to this SO question: What is the equivalent of boost::variant in the C++ standard library? it is mentioned that boost::variant and std::variant differ somewhat. What are the differenc...
Trochanter asked 23/10, 2016 at 9:19

3

The pattern that a lot of people use with C++17 / boost variants looks very similar to switch statements. For example: (snippet from cppreference.com) std::variant<int, long, double, std::strin...
Perithecium asked 16/8, 2017 at 7:45

2

Is there any way to get multiple variant details using multiple variant id in single shopify call. Actually, I want to get price of all product variant which are listed in order using shopify call....
Gentianella asked 1/12, 2018 at 11:59

3

Solved

Suppose I have an overload set, like so: class C { public: static void f(const A &); static void f(const B &); }; I'd like to do something like std::variant<A, B> v; // ... st...
Synchroscope asked 26/2, 2021 at 19:25

4

I have recently updated gcc and g++ to version 7.2. I would like to try out std::experimental::any and std::variant in particular, and I am using Qt 5.9.1 in QtCreator. So far I have written this ...
Almeida asked 6/10, 2017 at 17:26

© 2022 - 2024 — McMap. All rights reserved.