<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - SFINAE in template parameter list is 10x slower than SFINAE in return type"
href="https://bugs.llvm.org/show_bug.cgi?id=36158">36158</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>SFINAE in template parameter list is 10x slower than SFINAE in return type
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eniebler@boost.org
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19777" name="attach_19777" title="demonstrate severe compile-time degradation of SFINAE-in-tparam-list">attachment 19777</a> <a href="attachment.cgi?id=19777&action=edit" title="demonstrate severe compile-time degradation of SFINAE-in-tparam-list">[details]</a></span>
demonstrate severe compile-time degradation of SFINAE-in-tparam-list
Please find attached an example where compile times are 10x slower when a
SFINAE condition (std::enable_if) is located in a template parameter list, as
opposed to located in the return type.
Slow code:
template<typename That,
typename std::enable_if<(bool)That(), int>::type = 0>
constexpr friend dummy operator&&(dummy, bool_<That>) noexcept
{
return {};
}
Fast code:
template<typename That>
constexpr friend
typename std::enable_if<(bool)That(), dummy>::type
operator&&(dummy, bool_<That>) noexcept
{
return {};
}
REPRO:
(FAST)
clang++ -std=gnu++11 -DSFINAE_FAST -c sfinae-perf-bug.cpp -o /dev/null
(SLOW)
clang++ -std=gnu++11 -c sfinae-perf-bug.cpp -o /dev/null
On my machine, compiling with SFINAE_FAST defined takes 0.58s, where as without
the define, it takes 5.8s.
By comparison, gcc is also slower for SFINAE-in-template-parameter-list, but
"only" about 60%.
CONTEXT:
The popular range-v3 library makes extensive use of the
SFINAE-in-template-parameter-list to emulate concepts. This perf bug is
probably severely effecting compile times.</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>