Skip to content

Commit

Permalink
test SFINAE variants
Browse files Browse the repository at this point in the history
#test
  • Loading branch information
alandefreitas committed Jan 14, 2025
1 parent e4a2a00 commit 8dba8cd
Show file tree
Hide file tree
Showing 4 changed files with 1,018 additions and 0 deletions.
354 changes: 354 additions & 0 deletions test-files/golden-tests/metadata/sfinae.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,354 @@
= Reference
:mrdocs:

[#index]
== Global namespace


=== Types

[cols=2]
|===
| Name | Description

| <<A-09,`A`>>
| The partial specialization of A is enabled via a template parameter



| <<A-02,`A&lt;T, void&gt;`>>
| Specialization for floating point types



|===
=== Functions

[cols=2]
|===
| Name | Description

| <<f1,`f1`>>
| Enabled via return type



| <<f10,`f10`>>
| Enabled via type template parameter



| <<f2,`f2`>>
| Enabling a specified return type



| <<f3,`f3`>>
| Enabling a specified return type in another namespace



| <<f4,`f4`>>
| Enabled via return type with std&colon;&colon;enable&lowbar;if



| <<f5,`f5`>>
| Enabled via a non&hyphen;type template parameter with helper



| <<f6,`f6`>>
| Enabled via a non&hyphen;type template parameter without helper



| <<f7,`f7`>>
| Enabled via a non&hyphen;type template parameter using int instead of bool



| <<f8,`f8`>>
| Enabled via parameter without helper



| <<f9,`f9`>>
| Enabled via parameter with helper



|===

[#A-09]
== A


The partial specialization of A is enabled via a template parameter



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
class T,
class Enable = void&gt;
class A;
----




[#A-02]
== A&lt;T, void&gt;


Specialization for floating point types



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class T&gt;
class <<A-09,A>>&lt;T, void&gt;;
----




[#f1]
== f1


Enabled via return type



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class T&gt;
T
f1(T value);
----

[#f10]
== f10


Enabled via type template parameter



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
class T,
typename = void&gt;
void
f10(T* t);
----

=== Description


This pattern should not be used because the function signature is unmodified and therefore only supports one overload&period;

It&apos;s a common mistake is to declare two function templates that differ only in their default template arguments&period;

This does not work because the declarations are treated as redeclarations of the same function template (default template arguments are not accounted for in function template equivalence)&period;



[#f2]
== f2


Enabling a specified return type



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class T&gt;
int
f2(T value);
----

[#f3]
== f3


Enabling a specified return type in another namespace



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class T&gt;
std::size&lowbar;t
f3(T value);
----

[#f4]
== f4


Enabled via return type with std&colon;&colon;enable&lowbar;if



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class T&gt;
T
f4(T value);
----

[#f5]
== f5


Enabled via a non&hyphen;type template parameter with helper



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
class T,
bool = true&gt;
T
f5(T value);
----

[#f6]
== f6


Enabled via a non&hyphen;type template parameter without helper



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
class T,
bool = true&gt;
T
f6(T value);
----

[#f7]
== f7


Enabled via a non&hyphen;type template parameter using int instead of bool



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
class T,
int = 0&gt;
void
f7(T value);
----

[#f8]
== f8


Enabled via parameter without helper



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class T&gt;
T
f8(
T value,
void* = 0);
----

[#f9]
== f9


Enabled via parameter with helper



=== Synopsis


Declared in `&lt;sfinae&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class T&gt;
T
f9(
T value,
void* = 0);
----



[.small]#Created with https://www.mrdocs.com[MrDocs]#
Loading

0 comments on commit 8dba8cd

Please sign in to comment.