Boost logo

Boost :

From: Hamish Mackenzie (boost_at_[hidden])
Date: 2001-11-27 08:54:27

On Tue, 2001-11-27 at 03:09, Aleksey Gurtovoy wrote:
> > Assuming the comment refers to the names type_is and value_is , the
> > intent, of course, is let_type_be<...> and let_value_be<...> , but
> > those are just too awkward to type, methinks. Or maybe not, on second
> > thought. Hmm.
> It is! For instance, consider stuffing a type_list by a dozen of integer
> values (boost::mpl has value_list for that, but let's ignore it for the sake
> of the example); with the names you propose, it will be something like this:
> typedef type_list<
> let_value_be<int,1>, let_value_be<int,7>, let_value_be<int,5>,
> let_value_be<int,2>, let_value_be<int,4>, let_value_be<int,8>,
> let_value_be<int,9>, let_value_be<int,2>, let_value_be<int,0>,
> let_value_be<int,3>, let_value_be<int,9>, let_value_be<int,1>
> > values;
> IMO, there is too much visual clutter here, especially if you consider how
> little information the above declaration carries. Or, for example, here is a
> compile-time 'for' loop:

I think we can solve this. See Emily's post and my follow up.

Then we can create a class

template< class Type, Type value, class Tail >
class static_const_value_list
  static const Type head_value = Value;
  typedef Type head_type;
  typedef Tail tail_type;
  class nil {};

template< int Value, class Tail >
class int_list : public static_const_value_list< int, Value, Tail >

typedef RECURSIVE_5( int_list, 1, 2, 3, 4, 5 ) one_to_five;

We could transform this into a typelist of some kind of value class.


Boost list run by bdawes at, gregod at, cpdaniel at, john at