<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Increase limit of parameters in variadic template packs?"
href="http://llvm.org/bugs/show_bug.cgi?id=21628">21628</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Increase limit of parameters in variadic template packs?
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.5
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dimanne@ya.ru
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>template <class TUndInt, class TV>
constexpr TUndInt CalcMax(TV V) noexcept { return static_cast<TUndInt>(V); }
template <class TUndInt, class TV, class ...TVs>
constexpr TUndInt CalcMax(TV V, TVs... Vs) noexcept {
return static_cast<TUndInt>(V) > CalcMax<TUndInt>(Vs...) ?
static_cast<TUndInt>(V) : CalcMax<TUndInt>(Vs...);
}
template <class TVs, TVs... Vs>
class TClass {
static const auto MaxNotInc = CalcMax<TVs>(Vs...) + 1;
};
int main() {
TClass<int, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
> Object;
return 0;
}
If you shall try to compile above example, you get following error message:
$ clang++ --std=c++11 main.cpp
main.cpp:2:42: error: in-class initializer for static data member is not a
constant expression
constexpr TUndInt CalcMax(TV V) noexcept { return static_cast<TUndInt>(V); }
^
main.cpp:17:70: note: in instantiation of template class
'TClass<int, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24>' requested here
> Object;
^
1 error generated.
but it you decrease number of parameters by commenting out this line
, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
all works well.
$ clang++ --version
Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM
3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ uname -a
Linux DimanNeYa 3.16.0-24-generic #32-Ubuntu SMP Tue Oct 28 13:07:32 UTC 2014
x86_64 x86_64 x86_64 GNU/Linux</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>