Nathan Ridge wrote:
Sorry it took me a bit longer, but here are my ideas.... Code from Slide 12 of Andrei's presentation at Going Native 2012:
template<class T> struct container { ... static if(debug_mode<T>::value) { class const_iterator { ... }; static if(std::is_const<T>::value) { typedef const_iterator iterator; } else { class iterator { ... }; } } else { class const_iterator { ... }; clas iterator { ... }; } };
and my view would be that removing the "static" wouldn't change anything in the program - so why is it necessary.
template<class PointerWrapper> struct grab_pointer_type { static if(has_element_type<PointerWrapper>::value) { typedef typename PointerWrapper::element_type pointer_type; } else { typedef typename PointerWrapper::value_type pointer_type; } };
also in this example, removing the static wouldn't change the program in any way.
But the static_if is being used at class scope here - regular if statements cannot be used at class scope!
lol - I completely overlooked the fact this isn't a function - which was my original question. As I remember, andrei's other example could have been better handled with a static_assert - but I may be mis-remembering. the above case would be handled adequetly today with TMP which admitadly is an unwieldy syntax. Robert Ramey
Regards, Nate