The Battle for Wesnoth  1.15.1+dev
type_trait_aliases.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017-2018 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
16 #include "global.hpp"
17 
18 #include <type_traits>
19 
20 namespace utils
21 {
22 //
23 // These aliases are part of the standard starting with C++17.
24 // However, MSVC includes them as of VS 2015 Update 2, and they can also be implemented
25 // using variable templates in C++14.
26 //
27 #ifdef HAVE_CXX17 || defined(_MSC_VER) && _MSC_VER >= 1900
28 
29 using std::is_base_of_v;
30 using std::is_same_v;
31 
32 #else
33 
34 // is_base_of
35 template<typename Base, typename Derived>
36 static constexpr bool is_base_of_v = std::is_base_of<Base, Derived>::value;
37 
38 // is_same
39 template<typename T, typename U>
40 static constexpr bool is_same_v = std::is_same<T, U>::value;
41 
42 #endif // HAVE_CXX17
43 
44 } // end namespace utils
static constexpr bool is_same_v
static constexpr bool is_base_of_v