diff --git a/toonz/sources/include/tcg/numeric_ops.h b/toonz/sources/include/tcg/numeric_ops.h index 490f9b9..7743743 100644 --- a/toonz/sources/include/tcg/numeric_ops.h +++ b/toonz/sources/include/tcg/numeric_ops.h @@ -5,7 +5,6 @@ // tcg includes #include "traits.h" -#include "sfinae.h" #include "macros.h" // STD includes @@ -90,7 +89,7 @@ inline bool areNear(Scalar a, Scalar b, Scalar tolerance) { //------------------------------------------------------------------------------------------- template -inline typename tcg::disable_if::value, +inline typename std::enable_if::value, Scalar>::type mod(Scalar val, Scalar mod) { Scalar m = val % mod; @@ -99,7 +98,7 @@ mod(Scalar val, Scalar mod) { template inline - typename tcg::enable_if::value, Scalar>::type + typename std::enable_if::value, Scalar>::type mod(Scalar val, Scalar mod) { Scalar m = fmod(val, mod); return (m >= 0) ? m : m + mod; @@ -138,7 +137,7 @@ inline Scalar modShift(Scalar val1, Scalar val2, Scalar a, Scalar b) { \return Integral quotient of the division of \p val by \p d. */ template -inline typename tcg::disable_if::value, +inline typename std::enable_if::value, Scalar>::type div(Scalar val, Scalar d) { TCG_STATIC_ASSERT(-3 / 5 == 0); @@ -153,7 +152,7 @@ div(Scalar val, Scalar d) { */ template inline - typename tcg::enable_if::value, Scalar>::type + typename std::enable_if::value, Scalar>::type div(Scalar val, Scalar d) { return std::floor(val / d); } diff --git a/toonz/sources/include/tcg/sfinae.h b/toonz/sources/include/tcg/sfinae.h deleted file mode 100644 index 4b36c63..0000000 --- a/toonz/sources/include/tcg/sfinae.h +++ /dev/null @@ -1,101 +0,0 @@ -#pragma once - -#ifndef TCG_SFINAE_H -#define TCG_SFINAE_H - -/*! - \file sfinae.h - - \brief Contains template metafunctions that can be used to enable or - disable template class members. - - \details SFINAE (Substitution Failure Is Not An Error) is a C++ \a feature - that allows the compiler to silently discard failures in template - function instantiations during function overload resolution. -*/ - -#if defined(__APPLE_CC__) -#include -#endif - -namespace tcg { - -template -struct type_match { - enum { value = false }; -}; - -template -struct type_match { - enum { value = true }; -}; - -//------------------------------------------------------------------------ - -template -struct type_mismatch { - enum { value = true }; -}; - -template -struct type_mismatch { - enum { value = false }; -}; - -//======================================================================== - -template -struct enable_if_exists { - typedef B type; -}; - -//======================================================================== - -template -struct enable_if {}; - -template -struct enable_if { - typedef T type; -}; - -//======================================================================== - -template -struct disable_if { - typedef T type; -}; - -template -struct disable_if {}; - -//======================================================================== - -template -struct choose_if; - -template -struct choose_if { - typedef TrueT type; -}; - -template -struct choose_if { - typedef FalseT type; -}; - -//======================================================================== - -template -struct choose_if_match { - typedef NotMatchedT type; -}; - -template -struct choose_if_match { - typedef MatchT type; -}; - -} // namespace tcg - -#endif // TCG_SFINAE_H diff --git a/toonz/sources/include/tcg/tcg_sfinae.h b/toonz/sources/include/tcg/tcg_sfinae.h deleted file mode 100644 index f5fd237..0000000 --- a/toonz/sources/include/tcg/tcg_sfinae.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "sfinae.h" diff --git a/toonz/sources/include/tcg/traits.h b/toonz/sources/include/tcg/traits.h index 525a010..d4924ed 100644 --- a/toonz/sources/include/tcg/traits.h +++ b/toonz/sources/include/tcg/traits.h @@ -3,9 +3,6 @@ #ifndef TCG_TRAITS_H #define TCG_TRAITS_H -// tcg includes -#include "sfinae.h" - // STD includes #include @@ -78,170 +75,6 @@ struct remove_cref { typedef typename remove_const::type>::type type; }; -//**************************************************************************** -// TCG traits for function types -//**************************************************************************** - -template -class function_traits { - template - struct result; - - template - struct result { - typedef typename F::result_type type; - }; - - template - struct result { - typedef struct { } type; }; - - template - static typename enable_if_exists::type - result_fun(Q *); - static double result_fun(...); - - template - struct argument; - - template - struct argument { - typedef typename F::argument_type type; - }; - - template - struct argument { - typedef void type; - }; - template - - static typename enable_if_exists::type - argument_fun(Q *); - static double argument_fun(...); - - template - struct first_arg; - - template - struct first_arg { - typedef typename F::first_argument_type type; - }; - - template - struct first_arg { - typedef void type; - }; - template - - static typename enable_if_exists::type - first_arg_fun(Q *); - static double first_arg_fun(...); - - template - struct second_arg; - - template - struct second_arg { - typedef typename F::second_argument_type type; - }; - - template - struct second_arg { - typedef void type; - }; - - template - static typename enable_if_exists::type - second_arg_fun(Q *); - static double second_arg_fun(...); - -public: - enum { - has_result = - (sizeof(result_fun(typename tcg::traits::pointer_type())) == - sizeof(char)), - has_argument = - (sizeof(argument_fun(typename tcg::traits::pointer_type())) == - sizeof(char)), - has_first_arg = - (sizeof(first_arg_fun(typename tcg::traits::pointer_type())) == - sizeof(char)), - has_second_arg = - (sizeof(second_arg_fun(typename tcg::traits::pointer_type())) == - sizeof(char)) - }; - - typedef typename result::type ret_type; - typedef typename argument::type arg_type; - typedef typename first_arg::type arg1_type; - typedef typename second_arg::type arg2_type; -}; - -//----------------------------------------------------------------------- - -template -struct function_traits { - enum { - has_result = true, - has_argument = false, - has_first_arg = false, - has_second_arg = false - }; - - typedef Ret ret_type; - typedef void arg_type; - typedef void arg1_type; - typedef void arg2_type; -}; - -template -struct function_traits : public function_traits {}; - -template -struct function_traits : public function_traits {}; - -//----------------------------------------------------------------------- - -template -struct function_traits { - enum { - has_result = true, - has_argument = true, - has_first_arg = false, - has_second_arg = false - }; - - typedef Ret ret_type; - typedef Arg arg_type; - typedef void arg1_type; - typedef void arg2_type; -}; - -template -struct function_traits : public function_traits {}; - -template -struct function_traits : public function_traits {}; - -//----------------------------------------------------------------------- - -template -struct function_traits { - enum { has_result = true, has_first_arg = true, has_second_arg = true }; - - typedef Ret ret_type; - typedef Arg1 arg1_type; - typedef Arg2 arg2_type; -}; - -template -struct function_traits - : public function_traits {}; - -template -struct function_traits - : public function_traits {}; - //****************************************************************************** // TCG traits for output container readers //****************************************************************************** @@ -282,27 +115,6 @@ struct is_floating_point { enum { value = true }; }; -//----------------------------------------------------------------------- - -template -struct is_function { - enum { value = function_traits::has_result }; -}; - -template -struct is_functor { - template - static typename enable_if_exists::type result( - Q *); - - static double result(...); - - enum { - value = (sizeof(result(typename tcg::traits::pointer_type())) == - sizeof(char)) - }; -}; - } // namespace tcg #endif // TCG_TRAITS_H