I'm fairly new to Boost MPL (and meta programming in general) and I think I'm confused by the idea of templates vs types. A simple example I'm working with is trying to compute the length of a vector. The following compiles fine:
typedef mpl::vector_c< int, 0, 1, 2, 3, 4, 5, 6, 7 > myVector;
struct TestSize
{
template <typename mySequence> struct apply
{
typedef mpl::size<mySequence> type;
};
};
typedef TestSize::apply<myVector>::type result;
but if I add "::type" to the result of the size computation, like this:
struct TestSize
{
template <typename mySequence> struct apply
{
typedef mpl::size<mySequence>::type type;
};
};
typedef TestSize::apply<myVector>::type result;
then I get the error "error: nontype "boost::mpl::size::type [with Sequence=mySequence]" is not a type name".
Is this a situation where the template parameter is not deduced because it is in a nested namespace? Adding to my confusion is the fact that the following compiles:
struct TestSize
{
template <typename mySequence> struct apply
{
typedef mpl::size<mySequence> type;
typedef mpl::range_c<int, 0, type::type::value> myRange;
};
};
typedef TestSize::apply<myVector>::type result;
typedef TestSize::apply<textureIndices>::myRange range;
Why can I do "type::type::value" there, but not "size< mySequence>::type" on the line before?