Clang's libcxx std::integer_sequence implementation

There is not much to it

template<class T, T... I>
struct integer_sequence
{
    typedef T value_type;

    static constexpr size_t size() noexcept;
};

template<class T, T N>
    using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;

however in make_integer_sequence I have never seen the ellipsis used is such a way, assuming it is not some preprocessor voodoo. Could someone please explain it? It seems rather new, as clang 3.5 - trunk version I compiled on windows in Feb this year - will not compile it. Also I cannot seem to find anything related to C++14.

3 comments · 100% upvoted · other discussions

comments

i_just_comment

Are you sure that is the part that has the compiler error?

Is this the utility header file? If so, I think the snippet in question you are looking is in comments section. The actual implementation is further down the file. e.g.

template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked =
  typename __detail::__convert<size_t, _Tp>::template __result<typename __detail::__make<_Np>::type>::type;

template <class _Tp, _Tp _Ep>
struct __make_integer_sequence
{
    static_assert(is_integral<_Tp>::value,
                  "std::make_integer_sequence can only be instantiated with an integral type" );
    static_assert(0 <= _Ep, "std::make_integer_sequence input shall not be negative");
    typedef __make_integer_sequence_unchecked<_Tp, _Ep> type;
};

template<class _Tp, _Tp _Np>
    using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type;

template<size_t _Np>
    using make_index_sequence = make_integer_sequence<size_t, _Np>;

Look here: https://llvm.org/svn/llvm-project/libcxx/trunk/include/utility

solaeon [OP]

Legend! The compile error was because I was trying to compile the snippet of code in the OP.

The problem was because I did look at that link rather than using my editor on the local file I have, if I had I would had noticed that it was indeed a comment.

Also the comments look like real C++ code.

Thanks for taking time out of your day to help me out.

[deleted]

[deleted]

solaeon [OP]

Variadic Templates are related to parameter packing and unpacking; The make_integer_sequence definition appears to neither, it is a ... all on it's own.