variadic-templates Questions
3
Solved
I have a parameter pack given in a variadic class template and want to extract the first type.
Currently I do this, which works fine but is somehow cumbersome. Is it possible to do the same thing s...
Throw asked 8/8, 2017 at 21:44
8
Solved
The C++20 feature std::source_location is used to capture information about the context in which a function is called.
When I try to use it with a variadic template function, I encountered a probl...
Corissa asked 18/8, 2019 at 18:23
7
Solved
How can I make a class template that returns whether any of its variadic types are equal to the first type. I want to be able to do this:
is_same<T, A, B, C>::value; // true if T is one of A...
Ruyter asked 10/6, 2013 at 20:32
8
Solved
Is there a standard way to get the types of a function's arguments and pass around these types as a template parameter pack? I know that this is possible in C++ because it has been done before.
I ...
Catamaran asked 13/2, 2015 at 21:45
2
So I'm trying to make a type trait that says whether two "outer" class types are the same.
ie. std::vector<int> is the same as std::vector<double>, I don't care about any inner argumen...
Teniafuge asked 4/12, 2019 at 15:59
9
I know how to select first parameter of variadic template:
template< class...Args> struct select_first;
template< class A, class ...Args> struct select_first<A,Args...>{ using ty...
Sherard asked 22/9, 2013 at 9:30
1
Solved
I have the following type function to calculate whether some type T is part of the list of types in an std::tuple:
template<typename T, typename Tuple>
struct IsInTuple;
template<typename...
Kryska asked 4/4, 2024 at 8:55
2
I'm trying to use variadic templates to specify friend classes. I try with the following syntax, but it doesn't work.
template <class... Args>
struct A {
friend Args...;
};
I try to code ...
Ganof asked 26/4, 2014 at 2:40
1
Solved
I want to define a concept in C++ (<= C++20) to check if a type matches any of the types define in a type-list struct.
The following is my attempt so far:
template<typename... Types>
struc...
Metencephalon asked 12/3, 2024 at 9:38
1
Solved
I want to fill a tuple<Ts...> from a vector of variants. (NB: This question follows up on Creating a tuple from a folding expression return values , see 2nd comment to the answer )
Expanding ...
Helvetic asked 24/1, 2024 at 15:54
2
Solved
Suppose I have a constexpr array (of known bound) of static storage duration:
constexpr T input[] = /* ... */;
And I have an output class template that needs a pack:
template<T...> struct...
Stereography asked 3/7, 2014 at 18:5
10
Solved
I'm trying to find a method to iterate over an a pack variadic template argument list.
Now as with all iterations, you need some sort of method of knowing how many arguments are in the packed list,...
Presidio asked 29/8, 2011 at 13:16
6
Solved
The following paper is the first proposal I found for template parameter packs.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1603.pdf
At page 16, it talks about introducing two new op...
Sentinel asked 23/11, 2013 at 13:29
7
Solved
How do I reverse the types in a tuple? For example, I want reverse_tuple<std::tuple<int, char, bool>>::type to be std::tuple<bool, char, int>. I tried doing the following but it d...
Namedropping asked 18/6, 2013 at 20:15
8
Solved
I'm trying to figure out how to write a conecpt that checks that there are no repeated types in a variadic template.
I'm aware I can't call a concept recursively within itself, but if I could my so...
Queston asked 6/4, 2023 at 12:1
4
@cyberpunk_ is trying to achieve something and made some questions about it but all the chase boils down to this:
Is it possible to build a tool to enforce compile-time evaluation of a constexpr fu...
Bambi asked 13/1, 2013 at 23:1
5
Solved
I have a simple yet daunting problem I can't solve by myself. I have something like
template<class T, class... Args>
T* create(SomeCastableType* args, size_t numArgs)
{
return new T(static_...
Inscribe asked 21/2, 2013 at 23:17
1
Solved
Let's say I have a function sum that takes a variadic parameter pack.
This function needs to ADD UP all of the parameters of the parameter pack using the operator +.
NOTE: It CANNOT use the operat...
Biographer asked 17/7, 2023 at 4:45
2
Solved
Despite, the fact, we have std::max, I wanted to try if it is possible to make a Max version that takes variadic arguments and calls the Max recursively for finding the max element.
I saw similar p...
Mimeograph asked 10/7, 2023 at 12:30
3
Solved
I have two vectors:
std::vector<int> v1{ 1, 2, 3 };
std::vector<int> v2{ 4, 5, 6 };
I want to create an object of std::initializer_list which holds iterators to the first and last elem...
Program asked 10/7, 2023 at 11:15
2
Solved
I want to track where the creation of an object occurs using std::source_location. The following is a simplified example without the extra code to account for copy and movement of a Tracked object....
Boni asked 9/7, 2023 at 8:27
2
Solved
It seems that a pack argument can be expanded only in the place of a pack parameter of an alias template. This is not true for a class or a function template:
template <class T, class... Args&g...
Stripper asked 8/6, 2015 at 10:40
1
Solved
I am having trouble understanding how to forward the elements of a parameter pack in C++. Please take for example the code below:
#include <iostream>
void print(const int& value) {
std:...
Cofield asked 2/5, 2023 at 13:52
0
This post is not just about unresolved linker symbols in general, but about a variadic function in a class with a Q_OBJECT macro. The macro creates a lot of components automatically generated...
Quadratics asked 23/4, 2023 at 3:28
2
Solved
I want to design a compile-time-string class CTString that can e.g. be constructed from a parameter pack of string literals. This works using a comma-fold-expression (for this toy example, I tried ...
Louque asked 17/4, 2023 at 10:40
1 Next >
© 2022 - 2025 — McMap. All rights reserved.