Skip to content

Annotations for function template overloads with constrained template parameters are rendered incorrectly #1214

Description

@akrzemi1

When I say "constrained template parameter" I mean Stream S in the following declaration:

template <Stream S>
void f(S& s);

Here is the problem. I have an overload set concisting of three function templates that differ only by concept constraints. I am using constrained template parameter to express the concept constraints:

#pragma once

namespace mylib {

template <typename T>
concept Buffer = requires(T v) { v.b(); }; 

template <typename T>
concept MBuffer = requires(T v) { v.m(); }; 

template <typename T>
concept Stream = requires(T v) { v.s(); }; 

template <typename T>
concept Source = Stream<T> && requires(T v) { v.str(); }; 

/** gun overload 1
  * @param s1 stream
  */
template <Stream S, Buffer B> 
void gun(S s1, B m);

/** gun overload 2
  * @param s2 other stream
  */
template <Stream S, MBuffer B> 
void gun(S s2, B m);

/** gun overload 3
  * @param s3 source
  */
template <Source S, MBuffer B> 
void gun(S s3, B m);

} // namespace mylib

When I generate the documentation, they seem to be recognized as a single function, the annotations across three declarations gathered together, and the final single function specification is a meaningless blend of the three declarations:

Image

When I decide to switch my declartions from using constrained template parameters to equivalent declarations using requires-clauses:

template <typename S, typename B> 
  requires Stream<S> && Buffer<B>
void gun(S s1, B m);

template <typename S, typename B> 
  requires Stream<S> && MBuffer<B>
void gun(S s2, B m);

template <typename S, typename B> 
  requires Source<S> && MBuffer<B>
void gun(S s3, B m);

Then mrdocs renders three pages for three overloads, each separately documented using its annotations, as expected.

So, it looks like, unless function template overloads have requires-clauses are not recognized as overloads, and are instead treated as redeclarations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixSomething that is broken / incorrect behavior

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions