Questions tagged [parameter-pack]
171 questions
0
votes
0 answers
Link Error(LNK2019) when using parameter pack as parameter for class
I want to save different types of data in the class ContentField, so it has a private internal class Row which uses a template typename, so that it can save different types of data. So now in the Constructor of ContentField a parameter pack of a…

Bugsia
- 25
- 6
0
votes
1 answer
Purpose of std::index_sequence & void casting in bswap_impl
There are multiple questions here & here regarding type-casting to void.
My question is, what's the purpose of void casting (void)dummy_pack; in en.cppreference.com/w/cpp/language/fold? Is it to explicitly indicate the value of dummy_pack is ignored…

cpp
- 265
- 1
- 6
0
votes
1 answer
Parameter packs unable to resolve overloaded function
#include
#include
#include
#include
#include
template
class ObsNoti {
public:
template <
typename Ret,
typename Class,
typename... Args,
…

51k
- 1,381
- 3
- 12
- 22
0
votes
1 answer
re-using variadic templates defined inside a class template parameter for class members that also require variadic templates
Given this code:
template
class Foo{
typedef K valueTypeK;
typedef V valueTypeV;
};
template
class Bar{
public:
// capture Foo... parameter package
using FooTuple =…

user3641187
- 405
- 5
- 10
0
votes
2 answers
C++ variant to variant with only some overlapping types, why doesn't my version work?
C++17, multiple compilers. TL;DR, my intended question is:
Why doesn't my solution work under gcc, but under clang and msvc++? Am I missing a subtlety about pack expansion or comma-separated expression evaluation?
My variation on this question…

CodeWeaver
- 41
- 3
0
votes
0 answers
gcc compiler bug using std::forward(args)... for parameter pack in lambda
In the following snippet I try to create an API for the async function which can be provided by a functor and an arbitrary amount of parameters that will be used to invoke a function call in asynchronous context (simplified away in this snipped). If…

glades
- 3,778
- 1
- 12
- 34
0
votes
0 answers
Initialize an std::array of a class without a copy/move constructor?
Let's say I have a class without a default constructor called A.
I can create an array of A objects (e.g. l_Array in the below code) without copy/move constructors, but I have an error when the array is a member of another class (e.g. initializing b…

Guillaume BERLAND
- 41
- 5
0
votes
1 answer
std::string formatting like sprintf / printf and also allow for no arguments
I am trying to solve a problem just like this one: std::string formatting like sprintf: std::string formatting like sprintf
#include
#include
#include
template
std::string string_format( const…

scottc5
- 41
- 5
0
votes
1 answer
Concept for constraining parameter pack to string-like types or types convertible to string
I'm piecing together a C++20 puzzle. Here's what I want to do: Function append_params will concatenate the url together with additional query parameters. To make design this in a dynamic and extensible way, I wanted to write a concept such that
it…

glades
- 3,778
- 1
- 12
- 34
0
votes
3 answers
How can I pass a function name and variadic list of arguments to a function in C++?
Not a duplicate of What is std::invoke in c++?. That quesiton asks specifically about that one and only feature. This question asks about a concept which can be 100% solved withOUT that feature, and has multiple, alternative solutions, only some of…

Gabriel Staples
- 36,492
- 15
- 194
- 265
0
votes
2 answers
How to Store Variadic Template Arguments Passed into Constructor and then Save them for Later Use?
I am curious how one would go about storing a parameter pack passed into a function and storing the values for later use.
For instance:
class Storage {
public:
template
Storage(Args... args) {
//store args somehow
}
…

TwistedBlizzard
- 931
- 2
- 9
0
votes
1 answer
Variadic Template Unpacking for Operator Overloading
I have an enum, as given below.
I want to have operator overloading for this enum,.
typedef enum E
{
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
D = 1 << 3,
ANY = A | B | C | D,
}
E;
//Basic version
inline E operator |(E a, E b)
{
…

TechTotie
- 127
- 1
- 15
0
votes
1 answer
Applying a function to a parameter pack
I'm playing around with parameter packs, and I'm trying to apply a mapping via a lambda function which adds 1 to each member of the parameter pack as shown. However, I get the output 4 while 234 is expected.
#include
// method to print a…

marital_weeping
- 618
- 5
- 18
0
votes
1 answer
about c++ templates and parameter pack
template
void func(Cs... cs){
};
template
void func1(T s){
func(/* the problem */);
};
int main(){
char s[]="HI THERE!";
func1(s);
return 0;
}
so the func1() call…

joudia
- 65
- 5
0
votes
0 answers
Cost-efficient way of returning n-th object of parameter pack at runtime
Here's a problem that I'm scratching my head over: I want to return the n-th object of a variadic template parameter pack whereas the index is known only at runtime.
I could just put every parameter in a tuple and then access the tuple, however,…

glades
- 3,778
- 1
- 12
- 34