Questions tagged [parameter-pack]
171 questions
0
votes
0 answers
initialize a union with template parameter packs
I'm writing an engine with ECS and the data-oriented model. I'm trying to avoid inheritance and dynamic dispatch to avoid trashing the cache with every update() call. What I came up with was this:
struct transformComponent {
const unsigned short…

lenerdv
- 177
- 13
0
votes
3 answers
Is there a way to get the values in a parameter pack without using recursion?
I've seen many example codes that use recursion to extract the values from a parameter pack. Is there any way, other than recursion, to extract the values from a parameter pack?

Sapphire_Brick
- 1,560
- 12
- 26
0
votes
1 answer
Recursively unpacking a template pack for a parameter-less function
I'm trying to create a struct template with a variadic template type pack, that can deduct the sum of the size of all types passed in.
Below you find a simplified example, in the real-world context, the size computed is used to create further member…

PluginPenguin
- 1,576
- 11
- 25
0
votes
1 answer
Parameter pack expansion not compiling in c++
In c++, when I try to expand a parameter pack, it gives me the errors
"parameter packs not expanded with '...'" and
"error: expected ';' before '...' token"
Help would be very appreciated. I use mingw 8.2.0.
Code:
#include
using…

CrazyVideoGamer
- 754
- 8
- 22
0
votes
1 answer
C++ iterate template parameters
It's possible to fill the appropriate registers of a virtual machine based on the argument list and some logic using a C++17 fold, like…

gonzo
- 442
- 4
- 15
0
votes
1 answer
What is the simplest way to process the values of a template parameter pack in the correct order without using fold-expressions (C++11)
I would like to back-port the following code to C++11:
template
static void bar() { /* some code with compile-time optimizations for each value i */ }
template
void f()
{
((bar()),...);
}
The order of invocation of…

Come Raczy
- 1,590
- 17
- 26
0
votes
1 answer
Why does the class deduction guide fail when using a typedef?
In a piece of the code I currently write I make use of a class deduction guide. You can find the excerpt of the code stripped down to a simple (but meaningless example) below:
I've got a class User, which derives its first template parameter from…

mutableVoid
- 1,284
- 2
- 11
- 29
0
votes
3 answers
c++ : using parameter pack in constructors?
#include
class A
{
public:
A(bool b, int i)
: b_(b) , i_(i) {}
void print()
{
std::cout << b_ << " " << i_ << "\n";
}
private:
bool b_;
int i_;
};
class B
{
public:
…

Vince
- 3,979
- 10
- 41
- 69
0
votes
2 answers
Initialize more than one unknown base classes
If base class is unknown to library (it is known to client), it is not so difficult to handle its constructor. The code looks like:
template
struct AAAAA : public Parent
{
using Parent::Parent;
template
…

Chameleon
- 1,804
- 2
- 15
- 21
0
votes
1 answer
arduino parameter pack working without tuple
I'm trying to do a sketch that can return a parameter pack. I found a reference here:
tuple to parameter pack
I modify it to be even more generic and can return any type of object to a void function pointer.
That said, now I'm testing with arduino…

Nitrof
- 121
- 1
- 3
- 15
0
votes
2 answers
C++ - Declare pointer to function returning any type and getting any number of parameters
I was wondering if writing anything resembling this declaration (making use of the parameter pack) is possible.
decltype(auto) (*funcPtr)(...);
If possible, I would also like to know about alternative ways to declare such a pointer.

daniglezad
- 91
- 2
- 9
0
votes
3 answers
Filter types in a parameter pack
Im trying create a filtered type of a variadic template/parameter pack and also preserve ordering.
// example what im trying to accomplish
template
struct query
{
using filtered = typename filtered

Frans Bstrom
- 195
- 1
- 12
0
votes
1 answer
"iterating" over a std::tuple and having access to all the constructors
I am new to variadic templates, and I'm having a difficult time implementing this container class. What I want is to take a list of types, and then create a std::tuple that holds std::vectors of each type. The specific difficulty I was having is…

Taylor
- 1,797
- 4
- 26
- 51
0
votes
1 answer
Passing pointers to member to function object from template parameter pack
Bellow is sample code which demonstrates what I am trying to do.
basically I want to pass more than one pointer to member to class method which takes std::function object and variable number or arguments which are passed to target function…

metablaster
- 1,958
- 12
- 26
0
votes
0 answers
How to use types in a parameter pack?
I'm new to c++11 and trying to make a function that runs objects
template
void fun() {
// use T here, may be something like
// std::tuple_element>::type i;
// i.run();
}
I don't know how to…

Wiki Wang
- 668
- 6
- 23