From 8152173c39b5242a1703d0c605c5da274c2eb9db Mon Sep 17 00:00:00 2001 From: q66 Date: Thu, 14 Jan 2016 19:11:52 +0000 Subject: [PATCH] convert more traits --- ostd/functional.hh | 12 +++---- ostd/range.hh | 80 ++++++++++++++++++++++------------------------ 2 files changed, 43 insertions(+), 49 deletions(-) diff --git a/ostd/functional.hh b/ostd/functional.hh index 567d43d..1ad6485 100644 --- a/ostd/functional.hh +++ b/ostd/functional.hh @@ -510,11 +510,9 @@ namespace detail { }; template - struct FunctorInPlace { - static constexpr bool value = sizeof(T) <= sizeof(FunctorData) - && (alignof(FunctorData) % alignof(T)) == 0 - && IsMoveConstructible; - }; + constexpr bool FunctorInPlace = sizeof(T) <= sizeof(FunctorData) && + (alignof(FunctorData) % alignof(T)) == 0 && + IsMoveConstructible; struct FunctionManager; @@ -572,9 +570,7 @@ namespace detail { }; template - struct FunctorDataManager::value> - > { + struct FunctorDataManager>> { template static R call(const FunctorData &s, Args ...args) { return (*(AllocatorPointer &)s)(forward(args)...); diff --git a/ostd/range.hh b/ostd/range.hh index 5598150..36a578d 100644 --- a/ostd/range.hh +++ b/ostd/range.hh @@ -72,102 +72,102 @@ namespace detail { namespace detail { template, InputRangeTag>> - struct IsInputRangeCore: False {}; + constexpr bool IsInputRangeCore = false; template - struct IsInputRangeCore: True {}; + constexpr bool IsInputRangeCore = true; template::value> - struct IsInputRangeBase: False {}; + constexpr bool IsInputRangeBase = false; template - struct IsInputRangeBase: detail::IsInputRangeCore::Type {}; + constexpr bool IsInputRangeBase = detail::IsInputRangeCore; } template -constexpr bool IsInputRange = detail::IsInputRangeBase::value; +constexpr bool IsInputRange = detail::IsInputRangeBase; // is forward range namespace detail { template, ForwardRangeTag>> - struct IsForwardRangeCore: False {}; + constexpr bool IsForwardRangeCore = false; template - struct IsForwardRangeCore: True {}; + constexpr bool IsForwardRangeCore = true; template::value> - struct IsForwardRangeBase: False {}; + constexpr bool IsForwardRangeBase = false; template - struct IsForwardRangeBase: detail::IsForwardRangeCore::Type {}; + constexpr bool IsForwardRangeBase = detail::IsForwardRangeCore; } template -constexpr bool IsForwardRange = detail::IsForwardRangeBase::value; +constexpr bool IsForwardRange = detail::IsForwardRangeBase; // is bidirectional range namespace detail { template, BidirectionalRangeTag - >> struct IsBidirectionalRangeCore: False {}; + >> constexpr bool IsBidirectionalRangeCore = false; template - struct IsBidirectionalRangeCore: True {}; + constexpr bool IsBidirectionalRangeCore = true; template::value> - struct IsBidirectionalRangeBase: False {}; + constexpr bool IsBidirectionalRangeBase = false; template - struct IsBidirectionalRangeBase: - detail::IsBidirectionalRangeCore::Type {}; + constexpr bool IsBidirectionalRangeBase = + detail::IsBidirectionalRangeCore; } template constexpr bool IsBidirectionalRange - = detail::IsBidirectionalRangeBase::value; + = detail::IsBidirectionalRangeBase; // is random access range namespace detail { template, RandomAccessRangeTag - >> struct IsRandomAccessRangeCore: False {}; + >> constexpr bool IsRandomAccessRangeCore = false; template - struct IsRandomAccessRangeCore: True {}; + constexpr bool IsRandomAccessRangeCore = true; template::value> - struct IsRandomAccessRangeBase: False {}; + constexpr bool IsRandomAccessRangeBase = false; template - struct IsRandomAccessRangeBase: - detail::IsRandomAccessRangeCore::Type {}; + constexpr bool IsRandomAccessRangeBase = + detail::IsRandomAccessRangeCore; } template constexpr bool IsRandomAccessRange - = detail::IsRandomAccessRangeBase::value; + = detail::IsRandomAccessRangeBase; // is finite random access range namespace detail { template, FiniteRandomAccessRangeTag - >> struct IsFiniteRandomAccessRangeCore: False {}; + >> constexpr bool IsFiniteRandomAccessRangeCore = false; template - struct IsFiniteRandomAccessRangeCore: True {}; + constexpr bool IsFiniteRandomAccessRangeCore = true; template::value> - struct IsFiniteRandomAccessRangeBase: False {}; + constexpr bool IsFiniteRandomAccessRangeBase = false; template - struct IsFiniteRandomAccessRangeBase: - detail::IsFiniteRandomAccessRangeCore::Type {}; + constexpr bool IsFiniteRandomAccessRangeBase = + detail::IsFiniteRandomAccessRangeCore; } template constexpr bool IsFiniteRandomAccessRange - = detail::IsFiniteRandomAccessRangeBase::value; + = detail::IsFiniteRandomAccessRangeBase; // is infinite random access range @@ -179,21 +179,21 @@ template constexpr bool IsInfiniteRandomAccessRange namespace detail { template, ContiguousRangeTag - >> struct IsContiguousRangeCore: False {}; + >> constexpr bool IsContiguousRangeCore = false; template - struct IsContiguousRangeCore: True {}; + constexpr bool IsContiguousRangeCore = true; template::value> - struct IsContiguousRangeBase: False {}; + constexpr bool IsContiguousRangeBase = false; template - struct IsContiguousRangeBase: - detail::IsContiguousRangeCore::Type {}; + constexpr bool IsContiguousRangeBase = + detail::IsContiguousRangeCore; } template constexpr bool IsContiguousRange - = detail::IsContiguousRangeBase::value; + = detail::IsContiguousRangeBase; // is output range @@ -212,21 +212,19 @@ namespace detail { (detail::OutputRangeTest &>::value || detail::OutputRangeTest &&>::value || detail::OutputRangeTest >::value) - ))> struct IsOutputRangeCore: False {}; + ))> constexpr bool IsOutputRangeCore = false; template - struct IsOutputRangeCore: True {}; + constexpr bool IsOutputRangeCore = true; template::value> - struct IsOutputRangeBase: False {}; + constexpr bool IsOutputRangeBase = false; template - struct IsOutputRangeBase: - detail::IsOutputRangeCore::Type {}; + constexpr bool IsOutputRangeBase = detail::IsOutputRangeCore; } -template constexpr bool IsOutputRange - = detail::IsOutputRangeBase::value; +template constexpr bool IsOutputRange = detail::IsOutputRangeBase; namespace detail { // range iterator