Skip to content

New mangling rule for deduced default template arguments. #184

Open
@mizvekov

Description

@mizvekov

As part of https://isocpp.org/files/papers/P3310R0.html, we would like to introduce deduction of default template arguments.

When deducing a template template parameter from a template specialization, we propose to default any extra arguments the parameter side would not consume, thus effectively allowing a template template parameter to bind to a template declaration with less template parameters, even if the extra parameters aren't declared as defaulted in the template declaration.

Consider:

template<class T, class U> struct A {};
A<int, float> v;
template<template<class> class TT> void f(TT<int>);

// OK: TT picks 'float' as the default argument for the second parameter.
void g() { f(v); }

Since 'f' specialized from A<int, float> is different from 'f' specialized from A<int, double>, this will affect mangling and so we need new rules.

This should only affect template template arguments.

A class template specialization A<int, double> which was specialized as written, is still the same class when specialized from a template template parameter bound to A deduced from a different specialization.

I would like guidance with such a rule.

My initial idea would be that when mangling such a template template argument, we follow the template name with a number, which is a starting position from which the first argument is deduced, followed by the same mangling we currently use for a template argument list.

Thus:

template<class T, class U> struct A {};

template<template<class> class TT> void f(TT<int>);

void z() {
  f(A<int, double>());
}

This 'f' specialized with A<int, double> would be mangled as _Z1fITtTyE1A1IdEEvT_IiE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions