Simple std::enable_if example

Consider the following function: int negate(int i) { // (1) return -i; } and the following function template: template<class F> typename F::result_type negate(F const& f) { // (2) return -f(); } where F is some function object type (so that a member type F::result_type exists). Let…

counting_range vs irange

The main difference is that irange is a random-access range while counting_range isn't. counting_range is based on Boost.Iterator's counting_iterator which uses all the underlying integers operations directly. Integers in C++ almost fit the iterator concept: the only thing missing is an operator*. counting_iterator provides an…