From d01d72f8e746a7a7af2fe618d6079daef9cddc58 Mon Sep 17 00:00:00 2001 From: cmdrf Date: Fri, 12 Jun 2015 12:38:44 +0200 Subject: [PATCH] Update NV_FOREACH for C++11 --- src/nvcore/ForEach.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/nvcore/ForEach.h b/src/nvcore/ForEach.h index 6a86aca..bf30e2f 100644 --- a/src/nvcore/ForEach.h +++ b/src/nvcore/ForEach.h @@ -10,10 +10,15 @@ These foreach macros are very non-standard and somewhat confusing, but I like th #include "nvcore.h" -#if NV_CC_GNUC // If typeof is available: +#if NV_CC_GNUC || NV_CC_CPP11 // If typeof or decltype is available: +#if !NV_CC_CPP11 +# define NV_DECLTYPE typeof // Using a non-standard extension over typeof that behaves as C++11 decltype +#else +# define NV_DECLTYPE decltype +#endif #define NV_FOREACH(i, container) \ - typedef typeof(container) NV_STRING_JOIN2(cont,__LINE__); \ + typedef NV_DECLTYPE(container) NV_STRING_JOIN2(cont,__LINE__); \ for(NV_STRING_JOIN2(cont,__LINE__)::PseudoIndex i((container).start()); !(container).isDone(i); (container).advance(i)) /* #define NV_FOREACH(i, container) \