Loading src/TNL/Functional.h +35 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ namespace TNL { struct Plus : public std::plus< void > { template< typename T > static constexpr T getIdempotent() { return 0; }; static constexpr T getIdempotent() { return 0; } }; /** Loading @@ -32,7 +32,7 @@ struct Plus : public std::plus< void > struct Multiplies : public std::multiplies< void > { template< typename T > static constexpr T getIdempotent() { return 1; }; static constexpr T getIdempotent() { return 1; } }; /** Loading @@ -41,7 +41,12 @@ struct Multiplies : public std::multiplies< void > struct Min { template< typename T > static constexpr T getIdempotent() { return std::numeric_limits< T >::max(); }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::max(); } template< typename Value > constexpr Value operator()( const Value& lhs, const Value& rhs ) const Loading @@ -58,7 +63,12 @@ struct Min struct Max { template< typename T > static constexpr T getIdempotent() { return std::numeric_limits< T >::min(); }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::lowest(); } template< typename Value > constexpr Value operator()( const Value& lhs, const Value& rhs ) const Loading @@ -75,7 +85,12 @@ struct Max struct MinWithArg { template< typename T > static constexpr T getIdempotent() { return std::numeric_limits< T >::max(); }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::max(); } template< typename Value, typename Index > constexpr void operator()( Value& lhs, const Value& rhs, Index& lhsIdx, const Index& rhsIdx ) const Loading @@ -98,7 +113,12 @@ struct MinWithArg struct MaxWithArg { template< typename T > static constexpr T getIdempotent() { return std::numeric_limits< T >::min(); }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::lowest(); } template< typename Value, typename Index > constexpr void operator()( Value& lhs, const Value& rhs, Index& lhsIdx, const Index& rhsIdx ) const Loading @@ -121,7 +141,12 @@ struct MaxWithArg struct LogicalAnd : public std::logical_and< void > { template< typename T > static constexpr T getIdempotent() { return true; }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::max(); } }; /** Loading @@ -130,7 +155,7 @@ struct LogicalAnd : public std::logical_and< void > struct LogicalOr : public std::logical_or< void > { template< typename T > static constexpr T getIdempotent() { return false; }; static constexpr T getIdempotent() { return 0; } }; /** Loading @@ -139,7 +164,7 @@ struct LogicalOr : public std::logical_or< void > struct BitAnd : public std::bit_and< void > { template< typename T > static constexpr T getIdempotent() { return ~static_cast< T >( 0 ); }; static constexpr T getIdempotent() { return ~static_cast< T >( 0 ); } }; /** Loading @@ -148,7 +173,7 @@ struct BitAnd : public std::bit_and< void > struct BitOr : public std::bit_or< void > { template< typename T > static constexpr T getIdempotent() { return 0; }; static constexpr T getIdempotent() { return 0; } }; } // namespace TNL Loading
src/TNL/Functional.h +35 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ namespace TNL { struct Plus : public std::plus< void > { template< typename T > static constexpr T getIdempotent() { return 0; }; static constexpr T getIdempotent() { return 0; } }; /** Loading @@ -32,7 +32,7 @@ struct Plus : public std::plus< void > struct Multiplies : public std::multiplies< void > { template< typename T > static constexpr T getIdempotent() { return 1; }; static constexpr T getIdempotent() { return 1; } }; /** Loading @@ -41,7 +41,12 @@ struct Multiplies : public std::multiplies< void > struct Min { template< typename T > static constexpr T getIdempotent() { return std::numeric_limits< T >::max(); }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::max(); } template< typename Value > constexpr Value operator()( const Value& lhs, const Value& rhs ) const Loading @@ -58,7 +63,12 @@ struct Min struct Max { template< typename T > static constexpr T getIdempotent() { return std::numeric_limits< T >::min(); }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::lowest(); } template< typename Value > constexpr Value operator()( const Value& lhs, const Value& rhs ) const Loading @@ -75,7 +85,12 @@ struct Max struct MinWithArg { template< typename T > static constexpr T getIdempotent() { return std::numeric_limits< T >::max(); }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::max(); } template< typename Value, typename Index > constexpr void operator()( Value& lhs, const Value& rhs, Index& lhsIdx, const Index& rhsIdx ) const Loading @@ -98,7 +113,12 @@ struct MinWithArg struct MaxWithArg { template< typename T > static constexpr T getIdempotent() { return std::numeric_limits< T >::min(); }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::lowest(); } template< typename Value, typename Index > constexpr void operator()( Value& lhs, const Value& rhs, Index& lhsIdx, const Index& rhsIdx ) const Loading @@ -121,7 +141,12 @@ struct MaxWithArg struct LogicalAnd : public std::logical_and< void > { template< typename T > static constexpr T getIdempotent() { return true; }; static constexpr T getIdempotent() { static_assert( std::numeric_limits< T >::is_specialized, "std::numeric_limits is not specialized for the requested type" ); return std::numeric_limits< T >::max(); } }; /** Loading @@ -130,7 +155,7 @@ struct LogicalAnd : public std::logical_and< void > struct LogicalOr : public std::logical_or< void > { template< typename T > static constexpr T getIdempotent() { return false; }; static constexpr T getIdempotent() { return 0; } }; /** Loading @@ -139,7 +164,7 @@ struct LogicalOr : public std::logical_or< void > struct BitAnd : public std::bit_and< void > { template< typename T > static constexpr T getIdempotent() { return ~static_cast< T >( 0 ); }; static constexpr T getIdempotent() { return ~static_cast< T >( 0 ); } }; /** Loading @@ -148,7 +173,7 @@ struct BitAnd : public std::bit_and< void > struct BitOr : public std::bit_or< void > { template< typename T > static constexpr T getIdempotent() { return 0; }; static constexpr T getIdempotent() { return 0; } }; } // namespace TNL