1,277 questions
3
votes
2
answers
185
views
Problem with satisfying a C++ concept in a std::visit
I've a C++ concept where I need to check that the class has a particular public attribute.
My problem is that the concept works if I use it directly, but fails if I use it in std::visit.
This is the ...
0
votes
1
answer
64
views
What is "freezing" and how to declare a vector of variant record type?
I've written the next piece of code in order to declare a vector of lexical elements:
type Lexical_Element_Kind
is (
Delimiter, -- & ' ( ) * + , - . / : ; < = > |
-- => .. ...
0
votes
0
answers
44
views
Query Variant Data Type with Pyspark (Spark 4.0)
I use Spark 4.0 and have the following code
from pyspark.sql import SparkSession
from pyspark.sql import functions as F
from pyspark.sql.types import StringType
json_data = [
('{"auswahl&...
1
vote
0
answers
137
views
Conversion of a pyspark DataFrame with a Variant column to pandas fails with an error
When I try to convert a pyspark DataFrame with a VariantType column to a pandas DataFrame, the conversion fails with an error 'NoneType' object is not iterable. Am I doing it incorrectly?
Sample code:
...
0
votes
0
answers
89
views
How to select variant type saved in delta lake
I want save a csv file in delta lake table. In that file I have a column user that has the json value that in some rows the structure is different. And in the name I have Farsi character.
In delta ...
2
votes
3
answers
164
views
Polymorphism in std::variant when all template types are derived from the same base class
I want to store objects of different types in a std::set and rely on std::set's sorting to later access them by some key variable which is present in every type. To store different types I am using ...
0
votes
2
answers
90
views
initialize subclass of cuda::std::variant
I'm implementing polymorphism on GPU with std::cuda::variant, so far it's working with Circle, Square, Shape:
struct Circle;
struct Square;
using Shape = cuda::std::variant<Circle, Square>;
...
0
votes
0
answers
87
views
CLion WSL Toolchains: "No variants found" even though WSL distributions are installed
I'm trying to set up WSL as a toolchain in CLion. In Settings > Build, Execution, Deployment > Toolchains when I select WSL, the "Toolset" dropdown shows "No variants found", ...
0
votes
3
answers
131
views
Visit variant of nested classes : how to avoid redundant code?
I have a lot of polymorphic classes. Each of them has a nested class named Configuration containing all the hyperparameters required by the class. For each class tree, I create a variant of the ...
1
vote
0
answers
26
views
Is it possible to create a discount code for a specific variant using the BigCommerce API?
I’m working with the BigCommerce API and need to achieve the following:
Create Discount Code for a Variant:
Is it possible to create a discount code specifically for a variant (not the whole product), ...
0
votes
0
answers
96
views
Conditional Macro MS-Excel Interstore transfer project
I have a macro that I use for doing interstore transfers between stores and calculates stock transfers based on certain criteria. It loops through a list of sending stores and evaluates potential ...
0
votes
2
answers
68
views
Losing variant after using with to activate workbook
I have a workbook with lots of code in it that I have been using for many years. One of the worksheets has code that is supposed to create and populate a validation list with the names of folder names ...
1
vote
2
answers
140
views
Weird result of std::variant
I'm struggling with an odd behavior of the below code. The problem is that output of this snippet is "double". But we have an int in lhs.
I dug for a while and figured out the compiler put a ...
0
votes
0
answers
103
views
Precompile std::variant instantiation?
I am using a C++ std::variant with around 100 structs as possible choices. This type is used throughout my application and compile times tend to point to the instantiation and generation of various ...
2
votes
2
answers
278
views
Get a compile-time index to a std::variant when visiting it? [duplicate]
I have a std::variant of possibly repeated types, and I would like to increment the active index of the variant.
Here is an example demonstrating what I would like to do:
template <typename... Ts&...
1
vote
1
answer
122
views
Delphi 2009 can not compare '' with 333 while Delphi 6 could: "Could not convert variant of type (UnicodeString) into type (Double)" in Delphi 2009
I am trying to migrate a Delphi 6 application with TdxDBGrid to Delphi 2009, and for the time being I would like to keep TdxDBGrid, because it has features that TcxGrid does not (we're moving to ...
0
votes
1
answer
118
views
Displaying different button for specific variant
Having an issue where on this 2 variant product, the 100ml option when clicked should bring up Buy at Macy's. It only does if you go to the URL with the variant hard coded in.
This is my current ...
3
votes
2
answers
120
views
Building a std::variant of pointers of types in the alternatives of another std::variant
I'm given a std::variant of several types. I would like to write a trait that gives another std::variant of the pointer of the types of the first.
using MyVariant = std::variant<int, float>;
...
10
votes
1
answer
215
views
MSVC bug in fold expression using variant?
Consider following code:
#include <variant>
class A {};
class B {};
template<typename... Ts, typename Variant>
bool constexpr is_of(const Variant& variant)
{
return std::visit(
...
3
votes
1
answer
82
views
std::variant construction by type
I'm trying to understand construction of std::variant<Ts...> by giving it a value from which one of its Ts can be constructed. The reference says
std::variant<Types...>::variant
...
(4) ...
2
votes
2
answers
180
views
pushing a unique_ptr into a vector of variant unique_ptr
I am playing around with C++ and faced this problem.
If I have a variant that looks like this:
using Fruit = variant<Apple, Tomato>
and a vector of unique_ptr of Fruit:
vector<unique_ptr<...
0
votes
0
answers
43
views
GLib.Variant For the Type String 'ai' Giving Error On First Run
Here is the code from a gnome extension:
try {
log(``);
global.set_persistent_state('int_val', GLib.Variant.new_int16(0));
let state = global.get_persistent_state('n', 'int_val').get_int16(...
1
vote
3
answers
156
views
how to transform std::variant by applying specified function
I need to convert variant<type1, type2, ...> to another variant<ftype1, ftype2, ...> where ftypeN is the return type of function fn() invoked with parameter of typeN, subject to the ...
2
votes
4
answers
191
views
converting tuple to variant problems
I need to access a value in std::tuple by index at run time. For that purpose I wrote a function that returns a std::variant with the same types initialized for the specified index. Implementation ...
2
votes
0
answers
22
views
Variant prioritization tool- ACMG criteria assignment
I am trying to run a tool ("TAPES") for ACMG-based variant prioritization of a vep-annotated VCF file.
The tool works perfect with the toy_dataset that contains another vep-annotated vcf ...
1
vote
1
answer
605
views
Snowflake Copy Into with CSV File
I'm trying to run the snowflake copy into command using a snowflake staged CSV file.
my command looks like this COPY INTO test_table FROM @my_stage FILE_FORMAT = (TYPE = CSV SKIP_HEADER = 1) PURGE = ...
1
vote
1
answer
88
views
Creating a tuple using types information from another tuple
In my simulation engine, I have a SimulationObject template that I specialize for different type of SimulationObjects using a Tag. I also have a SimulationObjects type that lists all the ...
2
votes
2
answers
139
views
Deduce template parameters for std::variant template parameter
I have a template class that takes std::variant as a template parameter:
template<class T>
class X
{
};
X<std::variant<int, float>> x;
I want to add a constraint for T to be ...
2
votes
1
answer
99
views
Is required for class templates to be instantiated to use only pointer or reference to them? [duplicate]
When using just pointers/references to std::variant<T...> defined from T... where some of T is only forward declared - I have this problem that I cannot even use pointers nor references to this ...
0
votes
1
answer
120
views
Automatic return type deduction of std::variant for auto functions in C++
For this code:
struct A {};
struct B {};
auto f() -> std::variant<A, B>
{
if (true) return A();
return B();
}
Is it possible for a compiler to automatically deduce return type as ...
0
votes
0
answers
262
views
Proper use of variants with VT_RECORD and VT_BYREF
I need some better understanding of records stored in VARIANT.
If there is a VT_RECORD typed variant, it has the following structure (in 32-bit):
V->vt = VT_RECORD
V->DATA1 //(8 byte offset) ...
1
vote
2
answers
470
views
How to implement implicit casting and operators for std::variant wrapper class?
I'm trying to implement std::variant wrapper that would behave similarly to std::variant when it comes to assignment and creation but also allow implicit cast to all alternatives held by the variant.
...
1
vote
2
answers
140
views
I don't understand this initialisation of an std::array of lambda with pack expansion [duplicate]
I found the following code (by phoeen) instanciating a variant based on index at runtime:
template <typename... Ts>
std::variant<Ts...> make_variant(std::size_t i)
{
assert(i < ...
0
votes
1
answer
73
views
std::variant multiple return types in a function
I am attempting to retrieve the value stored in a return variable with a type of variant, but I am struggling to make it work. Do you have any ideas? :)
I've tried almost everything, including ...
3
votes
1
answer
75
views
Is it expected that Application.Run() in Excel reduces the number of dimensions of a returned xloper12 array? And is there a way to prevent this?
I wrote an XLL library to provide some functions written with the Excel C API.
When I return an array (as a xloper12 type xltypeMulti), I notice a strange behaviour. If the function returns an array n ...
-1
votes
1
answer
288
views
VBA - Why does For Each iterator need to be Variant [closed]
Why does the VBA compiler require For Each iterators to be of type Variant?
For example, this code will throw error:
Public Sub IterationTest()
Dim arr(1 To 4) As String
Dim str As String
arr(1) = &...
0
votes
1
answer
88
views
Using variant referances for the objects in c++
I have a template class that contains mutex and cv. I want to create different versions of this class and store it in a map with a enum key. Template class given as;
// A threadsafe-queue.
template &...
-1
votes
1
answer
114
views
gcc/msvc compile the following, clang does not. Is there a workaround?
#include <optional>
#include <variant>
#include <vector>
// A
static_assert(
std::optional<
std::vector< int >
>{ std::vector< int >{ 1, 2, 3 } }
);...
1
vote
1
answer
91
views
How do I access a uint64 in a VARIANT structure?
How do I access a uint64 in a VARIANT structure?
Eg:
VARIANT vtProp{};
hres = pclsObj->Get(L"FreeSpaceInPagingFiles", 0, &vtProp, 0, 0);
strSystemInfo.AppendFormat(L" Free Space ...
0
votes
1
answer
88
views
How do I assign a range and a 1d array to a 2d variant array?
I'm working on a particular problem wherein I have to read multiple columns from a "sheet" in "file". These columns are to be temporarily stored in a "fileArray" and ...
-1
votes
1
answer
147
views
How do you deep copy a variant of pointers in C++?
I have a std::variant whose alternatives are all pointers.
class a {
public:
int* placeholder;
a(a& _copy) { /* Does a deep copy */ }
}
class b {
// For demonstrational purposes, ...
0
votes
1
answer
631
views
Merging 2 VCF files using bcftools, however how should I update the fields according to 2 VCF files
I used bcftools merge to merge 2 VCF files, however, when I see the merged VCF file, I don't see the updated fields. Suppose if I am running 2 samples in 1 VCF file which are different and 2 samples ...
2
votes
1
answer
102
views
Program with std::variant works in msvc but not in gcc
I wrote the following program that works with msvc c++17 but rejected by gcc and clang. I want to know which compiler is right here.
Demo.
#include <variant>
struct C
{
std::variant<bool&...
0
votes
0
answers
26
views
How use buildConfigField to get dependencies version based on build environnement variant?
I would like to import Android dependencies in the gradle build file and I would like define a version for all my environnement build variant. Then I would like get this version to display it in my ...
0
votes
2
answers
57
views
VBA Function That Works with Range and Array
I am trying to write a UDF that takes either a range or an array from the user and iterates over it. If I declare it as a range like so:
Function Test(param As Range) As Variant
Dim total As ...
0
votes
2
answers
285
views
Implicit conversion from a struct
This is my struct which uses implicit casting on creating variable.
#include <string>
#include <variant>
using namespace std;
using val = variant<int, string, double, bool, long, long ...
1
vote
1
answer
145
views
C++ struct with anonymous union
---- updated -------------------------------------------
At first, I think that the problem I faced is trivially_copyable. In fact, even I give up making it trivially_copyable, it still can NOT be ...
1
vote
0
answers
106
views
In Delphi, Lookup entry to get a Boolean, puzzling return value
In a ClientDataSearch using Lookup, we're told that to determine if Lookup found an entry is to check whether the returned variant is null (VarIsNull).
This appear to NOT be correct if the field we ...
4
votes
0
answers
218
views
Initialize vector of variants results in long list of warnings
I wrote some code and with optimizer -O2 I got a lot of warnings while running with -O3 is silent! Also gcc trunk ( godbolt) compiles without warnings. Compiler/library bug or simply my code is wrong?
...
0
votes
1
answer
108
views
Updating VARIANT column
I need to transform some values in a variant column.
'eng' to 'english',
'sp' to 'spanish',
'un' to 'unknown'
Source Data:
Target Data:
CREATE OR REPLACE TABLE driver_info (
ID INTEGER,
...