August 2017
Intermediate to advanced
438 pages
14h 19m
English
We are going to see how the size of a template type can be converted to a variable of some type, and how that variable can be used for deducing the right function overload.
#include <boost/mpl/int.hpp> namespace detail { // Generic implementation. template <class T, class Tag> T process_impl(const T& val, Tag /*ignore*/) { // ... } // 1 byte optimized implementation. template <class T> T process_impl(const T& val, boost::mpl::int_<1> /*ignore*/) { // ... } // 4 bytes optimized implementation. template <class T> T process_impl(const T& val, boost::mpl::int_<4> /*ignore*/) { // ... } // 8 bytes optimized implementation. template <class T> T process_impl(const ...Read now
Unlock full access