C++ Template Metaprogramming
Solutions to the exercises throughout the book
Loading...
Searching...
No Matches

Present array dimensions as a numerical sequence. More...

Files

file  exercise-5-6.hpp
 Solution to Exercise 5-6.
 

Namespaces

namespace  exercise_5_6
 Encapsulate solution for Exercise 5-6.
 

Classes

struct  boost::mpl::begin_impl< exercise_5_6::dimensions_tag >
 Just wrap the sequence in an iterator. More...
 
struct  boost::mpl::end_impl< exercise_5_6::dimensions_tag >
 The end is a boost::mpl::void_ type. More...
 
struct  boost::mpl::deref< exercise_5_6::dimensions_iterator< S > >
 The iterator just contains a subset of the underlying sequence. More...
 
struct  boost::mpl::next< exercise_5_6::dimensions_iterator< S > >
 The sequence itself defines "next". More...
 

Functions

static void anonymous_namespace{chapter-5.cpp}::test_exercise_5_6 ()
 Tests for Exercise 5-6.
 

Detailed Description

Present array dimensions as a numerical sequence.

5-6. Write a sequence adapter template called dimensions that, when
     instantiated on an array type, presents the array's dimensions as a
     forward, non-extensible sequence:

typedef dimensions<char [10][5][2]> seq;
BOOST_STATIC_ASSERT( mpl::size<seq>::value == 3 );
BOOST_STATIC_ASSERT(( mpl::at_c<seq,0>::type::value == 2 ));
BOOST_STATIC_ASSERT(( mpl::at_c<seq,1>::type::value == 5 ));
BOOST_STATIC_ASSERT(( mpl::at_c<seq,2>::type::value == 10 ));

    Consider using the type traits library facilities to simplify the
    implementation.

Function Documentation

◆ test_exercise_5_6()

static void anonymous_namespace{chapter-5.cpp}::test_exercise_5_6 ( )
static

Tests for Exercise 5-6.

Definition at line 279 of file chapter-5.cpp.