Skip to content

wrong variadic template expansion #323

@dvirtz

Description

@dvirtz

in an expansion of

template<typename... Args> struct count;

template<>
struct count<> {
  static const int value = 0;
};

template<typename T, typename... Args>
struct count<T, Args...>
{
  static const int value = 1 + count<Args...>::value;
};

static_assert(count<int, double>::value == 2, 
              "2 elements");

the last expansion uses value instead of count<>::value:

/* First instantiated from: insights.cpp:11 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
struct count<double>
{
  static const int value = 1 + value;
};

#endif

https://cppinsights.io/s/2701bf6e

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions