variant Questions
1
Solved
The following code:
variant<string> x = "abc";
cout << get<string>(x) << "\n";
works fine under g++ (version 7.2). However, when compiled under clang++ (version 5.0) usin...
1
Solved
I'm in the process of updating a codebase that is currently using a custom equivalent of std::variant to C++17 .
In certain parts of the code, the variant is being reset from a known alternative, ...
4
I am wondering how std::visit return type conversions are supposed to work.
The context is the following:
I have a variant object and I want to apply (through std::visit) different functions depe...
1
Update
I narrowed down the problem to (probably! it's not entirely clear, even reading all I could find about the topic) that installing stdlibc++-7-dev would provide me with suitable (i.e., C++17...
1
Solved
With std::variant<int, bool> I can call std::get<0>(var) to get the value in the variant as it's first type - int.
How can I do this with boost::variant? boost::get<> seems to su...
Leyva asked 14/8, 2017 at 14:28
1
Solved
I'm playing with std::variant, lambdas and std::future, and got super weird results when I tried to compose them together. Here are examples:
using variant_t = std::variant<
std::function<s...
3
I would like to use a boost.variant<T0,T1,T2> as a parameter to a template 'Visitor' class which would provide visitor operators as required by the boost.variant visitor mechanism, in this ca...
Latter asked 31/8, 2010 at 19:11
2
Solved
My std::variant can be empty (std::monostate), contain an int, a std::string or a bool.
When I want to feed it with a string, given as var = "this is my string", it gets converted to a bool and no...
1
Solved
The following code compiles well:
int main()
{
variant<any> var;
var = 5;
cout << any_cast<int>(get<any>(var)) << endl;
return 0;
}
But when I'm trying to put v...
2
Solved
Trying to get more familiar with C++17, I've just noticed std::visit:
template <class Visitor, class... Variants>
constexpr /*something*/ visit(Visitor&& vis, Variants&&... v...
Catholicism asked 5/5, 2017 at 18:37
3
Solved
I've written a component who has a Variant property for which I would like to set a default value.
TMyComponent = class(TComponent)
private
FVariantValue : Variant;
published
property VariantVal...
Nikianikita asked 13/4, 2017 at 14:15
3
Solved
It is nice to have a wrapper for every primitive value, so that there is no way to misuse it. I suspect this convenience comes at a price. Is there a performance drop? Should I rather use bare prim...
2
Solved
I am designing a parser for verilog language, and one of the rule have 25 components, which I need a large boost::variant to hold it:
typedef boost::variant<
shared_ptr<T_module_item__port_...
Naidanaiditch asked 10/1, 2016 at 6:5
3
Solved
I need to create an union, but 2 members of the union would have the same type, thus I need a way to identify them. For example in OCaml :
type A =
| B of int
| C of float
| D of float
Boost...
2
I have Delphi 2006 client application. This client recieves an Olevariant type data from COM server. The function is:
procedure OnLimitsChanged(var SymbolsChanged: {??PSafeArray}OleVariant);
Thi...
1
Solved
Please take a look at the latest updates at the end of the post.
In Particular, see Update 4: the Variant comparison Curse
I’ve already seen mates banging their head against the wall to underst...
Latashalatashia asked 20/2, 2017 at 21:8
0
I have in my PHP code, a COM object '$com_myObject' with a method 'myObjectMethod' which after I run
com_print_type info($com_myObject);
on it, it shows that it has the method 'myObjectMethod' d...
1
I am calling a COM object method that returns an array variant object of type 8209 in my PHP code.
$com_VArray = $com_Object->objectMethod; //Is a 8209 variant object
I want in the end to pas...
5
Solved
I'm in the process of creating a class that stores metadata about a particular data source. The metadata is structured in a tree, very similar to how XML is structured. The metadata values can be i...
0
In PHP, I want to pass an array of bytes reference to a COM object method whose syntax in VB is:
object.VBObjectMethod(ByRef aRawData() As Byte)
where parameter aRawData is an array of bytes that ...
2
Solved
std::variant provides the following access functions:
std::get_if: take pointer to variant, return pointer to alternative.
template <std::size_t I, typename... Ts>
auto* std::get_if(std:...
2
Solved
How can I use std::variant in g++? Why isn't there std::variant in std::experimental (though std::optional is)? What version of g++ do I need? I prefer not to use boost and I'd like to use standard...
3
Solved
I have tried different approaches and asked several specific questions regarding sub-problems of my requirement here. But my solution doesn't really work as expected, so I am taking a step back and...
Eal asked 16/12, 2016 at 15:21
1
Solved
I would like to visit a "recursive" std::variant using lambdas and overload-creating functions (e.g. boost::hana::overload).
Let's assume I have a variant type called my_variant which can store...
Cypro asked 2/10, 2016 at 17:20
1
Solved
I've learned there is a std::variant type in c++17.
Looks like there are no predefined data types supported by the variant container but for each variant type the user may define her own data-type...
© 2022 - 2024 — McMap. All rights reserved.