278 questions
2
votes
0
answers
103
views
Concept constraints for outer definitions of methods of a class with template template parameter
Usually I define my template classes as following (template<template<class> class T> is essential here):
// Foo.h
template<template<class> class T>
class Foo {
void foo();
...
3
votes
2
answers
162
views
Template template with container argument in C++17
To create a C++ class template that takes a standard container as a template argument I would do something like
#include <vector>
template <template<typename U,typename A=std::allocator&...
3
votes
0
answers
177
views
Why does C++26 still not allow passing a function template as a template parameter?
In C++26, the following code is legal (see p2841r7 and Herb Sutter's article):
template<typename<typename> concept C, template<typename> auto vt, typename T>
requires C<T>
auto ...
-1
votes
1
answer
111
views
How do I specify a default value for a template template parameter? [duplicate]
I have a function which takes a template template parameter, e.g.:
template <template <typename K, typename V> typename Map>
void foo();
I want to specify a default value for Map; namely, ...
2
votes
1
answer
82
views
variadic-value-template-template with value-types given in parent template is accepted by clang but rejected by gcc
I'm building trait-types (similar to std::type_identity) to represent template-templates of the different flavors. Mixed-type variadic value templates are a special case, and I can only think of doing ...
1
vote
0
answers
46
views
Template-template function overloading ambiguity error using gcc
I have this code perfectly working on clang
template <template <typename, typename> typename T>
struct CollectIntoAllocatedContainer
{
// ...
};
template <template <typename, ...
1
vote
2
answers
98
views
Template function member as template parameter
I want to call different template member functions with the same sequence of input types, in order to reduce boilerplate code, I tried to implement a dispatcher function, for_each_type,
struct A {
...
2
votes
1
answer
75
views
How do I use partial specializations as template template parameters?
I have a class template taking a template template parameter
template<template<class> typename T>
struct S {};
and a class template taking 2 template parameters
template<size_t i, ...
0
votes
1
answer
69
views
C++ TypeList with template types has index and type operations that don't work together
For a project I'm working on I have been trying to implement a typelist with template class.s as the possible types. The relevant parts of my implementation are below. It works well generally but it ...
0
votes
1
answer
107
views
How to work around MSVC not deducing template template argument
There is a very similar question, but I did not understand how I could apply the workarounds to my code. It was more about achieving generality across different container types: Visual C++ cannot ...
1
vote
0
answers
36
views
template template concepts to allow concepts to be templated on other concepts? [duplicate]
In C++20, is it possible for a concept to be templated on another concept?
I can do
template <typename R>
concept RangeOfFloats = std::ranges::range<R> && std::floating_point<...
1
vote
1
answer
110
views
An alternative for C++ not allowing templated type aliases?
Imagine a library has class templates A and B:
template <template <class> class T> class A;
template <class T, class U> class B;
Now, if a user of the library wants to pass B as an ...
0
votes
1
answer
101
views
Is it possible to write a C++ template function whose template arg works if-and-only-if it is template? [duplicate]
I'm trying to write a little template function that returns sequential integer id's for templates passed to it. The following works for many templates, but not for templates that take non-type ...
1
vote
2
answers
95
views
how do I "tighten up" arguments to a templatized function?
I have two related types (duck-typing), and another one that provides similar functionality with a different interface:
namespace a
{
template<typename T>
struct A final {};
using ...
1
vote
2
answers
75
views
Enforcing a common template type parameter among two template type parameters that are themselves templates
In C++, is there any way to ensure that two or more template type parameters are themselves template types with a common template type parameter?
Let's say that I have this:
struct ArbitraryType {};
...