1 /*! 2 * \file ResultOf.hxx 3 * \brief 4 * \author Thomas Helfer 5 * \date 14 févr. 2015 6 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights 7 * reserved. 8 * This project is publicly released under either the GNU GPL Licence 9 * or the CECILL-A licence. A copy of thoses licences are delivered 10 * with the sources of TFEL. CEA or EDF may also distribute this 11 * project under specific licensing conditions. 12 */ 13 14 #ifndef LIB_TFEL_METAPROGRAMMING_RESULTOF_HXX 15 #define LIB_TFEL_METAPROGRAMMING_RESULTOF_HXX 16 17 #include<type_traits> 18 #include"TFEL/Metaprogramming/InvalidType.hxx" 19 #include"TFEL/Metaprogramming/IsConstCallable.hxx" 20 21 namespace tfel{ 22 23 namespace meta{ 24 25 template<bool isCallable,typename,typename...> 26 struct ResultOfDispatch 27 { 28 typedef InvalidType type; 29 }; 30 31 template<typename T,typename... Args> 32 struct ResultOfDispatch<true,T,Args...> 33 { 34 using type = decltype(std::declval<T>()(std::declval<Args>()...)); 35 }; 36 37 template<typename T,typename... Args> 38 struct ResultOf 39 : ResultOfDispatch<IsConstCallable<T,Args...>::cond,T,Args...> 40 {}; // end of struct ResultOf 41 42 template<typename... Args> 43 struct ResultOf<InvalidType,Args...> 44 { 45 typedef InvalidType type; 46 }; // end of struct ResultOf 47 48 } // end of namespace meta 49 50 } // end of namespace tfel 51 52 #endif /* LIB_TFEL_METAPROGRAMMING_RESULTOF_HXX */ 53 54