template-aliases Questions
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
This code compiles
template<typename T>
struct A {
struct Inner {} inner;
void foo(Inner in);
};
template<typename T>
void A<T>::foo(typename A<T>::Inner in) {
}
int ma...
Stenotype asked 6/6, 2023 at 16:20
2
Solved
In C++ 11, I want to make a template alias with two specializations that resolve to a different function each.
void functionA();
void functionB();
template<typename T = char>
using Loc_snpri...
Wofford asked 23/8, 2022 at 11:29
1
Solved
With C++20, it is possible to have deduction guidelines generated for an alias template (See section "Deduction for alias templates" at https://en.cppreference.com/w/cpp/language/class_te...
Brunabrunch asked 21/11, 2020 at 3:0
1
Solved
Consider the following:
template <typename T, std::size_t N>
struct my_array
{
T values[N];
};
We can provide deduction guides for my_array, something like
template <typename ... Ts&g...
Loveinidleness asked 13/1, 2019 at 20:44
1
Solved
I encountered a very strange compiler error. For some reason the posted code does compile properly with g++ (7.3.0) while clang (7.0.0) fails:
../TemplateAlias/main.cpp:64:9: error: no matching fu...
Aldredge asked 26/11, 2018 at 16:20
1
Solved
After a while I discovered again a power of template template-parameters. See e.g. the following snippet:
template <template <class> class TT, class T>
void foo(TT<T>) {
}
templ...
Jovia asked 8/10, 2017 at 11:58
1
Solved
I want to determine the underlying template of a template parameter by using a combination of a template alias and template specializations. The follwing code compiles fine on gcc 4.8, 6.2.1 but no...
Aestivation asked 12/9, 2016 at 20:48
1
Solved
The port of some C++11 code from Clang to g++
template<class T>
using value_t = typename T::value_type;
template<class>
struct S
{
using value_type = int;
static value_type const C ...
Gerdi asked 13/1, 2017 at 19:45
2
Solved
In my app I would like to pass in a parameter pack over a legacy function signature, and change the values. Here is code that illustrates my question with my attempts as comments:
#include <tup...
Wilinski asked 13/12, 2016 at 22:22
1
Solved
Consider the following code:
template<typename F>
struct S;
template<typename Ret, typename... Args>
struct S<Ret(Args...)> { };
template<typename... Args>
using Alias = ...
Tharp asked 8/3, 2016 at 22:43
1
Solved
Why can't I declare a templated type alias inside of a function?
#include <vector>
int main(){
//type alias deceleration:
template <typename T>
using type = std::vector<T...
Planogamete asked 22/12, 2015 at 15:50
1
Solved
Consider the following:
template<typename X>
struct Z {};
struct A
{
using Z = ::Z<int>;
struct B : Z
{
using C = Z;
};
};
This compiles fine. Nice. But now add another parame...
Blackfellow asked 17/11, 2015 at 0:0
2
Imagine we have this code:
template <class, class>
class Element
{};
template <class T>
class Util
{
public:
template <class U>
using BeFriend = Element<T, U>;
};
Is it ...
Valdemar asked 6/11, 2015 at 9:26
1
Let's consider a set of template aliases:
template<class T> using foo = T*;
template<class T> using bar = T*;
template<class T> using buz = foo<T>;
template< template&l...
Mafalda asked 16/3, 2015 at 15:22
1
Solved
Is it possible to explicitly instantiate a template class through a template alias?
If so, how? Otherwise, can someone point to the ISO paper in which this was discussed and decided against?
temp...
Byssinosis asked 4/8, 2014 at 11:59
1
Solved
I run into a problem with unpacking variadic templates into a template alias.
The following code works with Clang 3.4 and GCC 4.8 but fails with GCC 4.9:
template <typename T, typename...>
...
Legend asked 26/6, 2014 at 14:50
1
Template aliases are very convenient in simplifying types like typename F <T>::type to just F <T>, where T and type are types.
I would like to do the same for templates like F <T>...
Christiansand asked 9/9, 2013 at 13:59
2
Solved
I am working on cross-platform code that needs shared pointers. For reasons beyond my control we cannot use C++11 just yet. So, I have suggested using boost::shared_ptr. When we do adopt C++11 (may...
Twotone asked 8/4, 2014 at 6:5
1
Solved
The following program...
#include <iostream>
#include <type_traits>
template <typename T>
struct Template{};
template <typename T>
using Alias = Template<T>;
templ...
Anaya asked 6/4, 2014 at 9:14
2
This is a follow-up of another question. It refers to the same problem (I hope) but uses an entirely different example to illustrate it. The reason is that in the previous example only experimental...
Popple asked 29/11, 2013 at 18:8
2
Solved
I need to use type aliases via using (or any other method) in situations like this:
template <class T>
typename std::enable_if< /*HERE*/>::value
f (...) {};
Where I wrote HERE there ...
Alumnus asked 27/12, 2013 at 12:22
1
First some code, then some context, then the question:
template <typename T> using id = T;
template <template <typename...> class F, typename... T>
using apply1 = F <T...>...
Laszlo asked 27/11, 2013 at 21:32
1
Solved
I want to rename a templated class. To make the transition easier for the users, I'd like to keep the old class for one more version and mark it deprecated with the extensions from GCC / Clang (att...
Churrigueresque asked 5/11, 2013 at 14:56
4
Solved
In C++11 you can create a "type alias" by doing something like
template <typename T>
using stringpair = std::pair<std::string, T>;
But this is a deviation from what you'd expe...
Pelagianism asked 17/10, 2013 at 22:26
1 Next >
© 2022 - 2024 — McMap. All rights reserved.