Schnek
traits.hpp
1 /*
2  * traits.hpp
3  *
4  * Created on: 1 Dec 2022
5  * Author: Holger Schmitz
6  * Email: holger@notjustphysics.com
7  *
8  * Copyright 2012-2022 Holger Schmitz
9  *
10  * This file is part of Schnek.
11  *
12  * Schnek is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * Schnek is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with Schnek. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 
28 #ifndef SCHNEK_UTIL_TRAITS_HPP
29 #define SCHNEK_UTIL_TRAITS_HPP
30 
31 namespace schnek {
32 
36  template <class Fn, class... Args>
37  struct is_invocable
38  {
39  template <class U>
40  static auto test(U* p) -> decltype((*p)(std::declval<Args>()...), void(), std::true_type());
41  template <class U>
42  static auto test(...) -> decltype(std::false_type());
43 
44  static constexpr bool value = decltype(test<Fn>(0))::value;
45  };
46 
47 } // namespace schnek
48 
49 #endif SCHNEK_UTIL_TRAITS_HPP
Determines whether Fn can be invoked with the arguments Args....
Definition: traits.hpp:37
Definition: algo.hpp:30