Questions tagged [sfinae]

Substitution failure is not an error (SFINAE) refers to a situation in C++ where an invalid substitution of template parameters is not in itself an error. This exploit can be used as a means to implement several template metaprogramming techniques.

Filter by
Sorted by
Tagged with
5
votes
1answer
48 views

Emulating Virtual Registers Part 3

Forward This is a continuation of my work in progress and the last iteration that I posted can be found here. I have designed a compact class template that uses SFINAE with constructor delegation to ...
7
votes
0answers
118 views

C++17 is_integral trait implementation

This is a C++17 is_integral trait implementation. Most implementations exhaust all integral types: bool ...
3
votes
1answer
142 views

Implementation of static_vector using an array of std::aligned_storage, with std::launder and forwarding

I'm trying to expand on the implementation of static_vector on the std::aligned_storage reference page, but would like to split it into two parts. First, an ...
10
votes
3answers
1k views

`sfinae</* … */>` proposal… useful or unnecessary?

I am trying to learn what SFINAE is. I believe I understand it quite well; however, I do not have a lot of practice in the subject. I mean I would find it difficult to list all the cases in which <...
5
votes
0answers
133 views

Using SFINAE with wrappers to terminate compilation early

The Goal Provide some wrappers to a C++11 template library's main entry point so that if the initial template parameter is not valid, the user is informed of exactly what is missing. In the real ...
5
votes
1answer
81 views

Set an order or precedence when calling functions that may or may not exist

In the process of over-engineering a custom library, I implemented expression SFINAE to detect and call specific member functions only if they exist. I also let classes overload these functions and ...
0
votes
1answer
58 views

SFINAE with several condition [Refactoring] [closed]

How can I write this function shorter? ...
8
votes
1answer
1k views

C++ template type traits for class members

I have written type traits for checking, if given class T has_member, then if it either ...
11
votes
3answers
787 views

C++ Vector The basics

Following on from my two previous posts. An alternative vector An Alternative Vector (Copy Assignment Operator) I have written a detailed blog about how to write a minimal vector like class. This ...
5
votes
1answer
3k views

A trait class to detect whether a template is specialized for a given type

Today's question will just be about a small utility that I needed at some point for one of my projects: a template to detect whether a template is specialized for a given type. The utility uses ...
9
votes
1answer
4k views

Continuation Implementation in C++11

While playing with the concurrency features in C++11 I noticed that there wasn't any support for continuations. I wanted to develop something similar to Tasks in The Parallel Patterns Library (PPL), ...
3
votes
3answers
616 views

Use of macros to aid visual parsing of SFINAE template metaprogramming

I've recently been introduced to SFINAE to solve the problem of unwanted promotion precedence. i.e. I was hoping to catch integer types with Foo::Foo(long) and ...