-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic_false.hpp
35 lines (31 loc) · 951 Bytes
/
static_false.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef talbi__STATIC_FALSE_HPP
#define talbi__STATIC_FALSE_HPP
#include <type_traits>
namespace talbi {
/*
* static_false<T> is a struct which has the compile-time ::value of false.
*
* Usage. Use in template functions on which you don't want to provide implementations,
* for use with static_assert.
* Rational. static_assert(false, str) will simply not compile, thus making the code below
* to not compile:
*
* template<class T> auto f(const T&);
*
* template<>
* auto f(const std::string& s) {
* std::cout << s << '\n';
* }
*
* template<class T>
* auto f(const T&) {
* static_assert(false, "Not implemented.");
* }
*
*
* replacing false with static_false<T>::value, however, will compile successfully.
* */
template<class T>
struct static_false : std::false_type {};
};
#endif //talbi__STATIC_FALSE_HPP