As mentioned in a post of comp.std.c++:

  http://preview.tinyurl.com/yaqvnnq

there's a need for some way to get the nth element of a pack
expansion.  For example, boost::mpl::arg:

  http://www.boost.org/doc/libs/1_40_0/libs/mpl/doc/refmanual/arg.html

wouldn't need the preprocessor for its implementation.  Instead, using
something like the following grammar production:

  get-nth-expansion-element:
    expansion-pattern '...[' constant-expression ']'

  where:
    expansion-pattern is the "pattern of the expansion" described
      on p. 327 of:

       http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n3000.pdf

    constant-expression is defined here:

      http://www.csci.csusb.edu/dick/c++std/cd2/gram.html#gram.expr

then boost::mpl::arg would be simply implemented as:

  template< int n > struct arg
  {
      template< typename A...>
      struct apply
      {
          typedef A...[n] type;
      };
  };

where:

  A is parsed as a expansion-pattern.
  n is parsed as a constant-expression.

Could g++ provide this feature?  How hard would it be to implement.  I
would think it would just involve defining a new token:

  ...[

and then, wherever a expansion-pattern is currently parsed, this
would be followed by a test for whether the next token
is:

  ...

or:

  ...[

TIA.


-regards,
Larry

Reply via email to