<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 - compilation error while trying to deduce type from a struct which takes variadic paramter"
href="https://bugs.llvm.org/show_bug.cgi?id=36773">36773</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>compilation error while trying to deduce type from a struct which takes variadic paramter
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>enhancement
</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>ranjith.tv@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Below code block is not compiling on clang, is building fine with other
compilers
#include <iostream>
#include <vector>
#include <functional>
#include <memory>
class TaskScheduler {
public:
TaskScheduler() = default;
virtual ~TaskScheduler() {}
template <typename... TParam>
struct Callback {
using Type = std::function<void(TParam...)>;
};
template<typename TCallback, typename... TRequestParam>
void queue(void (*requestFunction)(TRequestParam..., typename
TCallback::Type),
TRequestParam... args, typename TCallback::Type callback) {
doQueue([this, requestFunction, args..., callback](){
requestFunction(args..., callback);
});
}
void fire() {
if (mTasks.empty()) {
std::cout << "No task" << std::endl;
}
for (auto &task: mTasks) {
task();
}
mTasks.clear();
}
protected:
void doQueue(std::function<void()> task) {
mTasks.push_back(task);
}
std::vector<std::function<void()>> mTasks;
};
class Test1 {};
class Test2 {};
class Test3 {};
void function1(Test1 *a1, std::shared_ptr<Test2> a2,
std::function<void(std::shared_ptr<Test2>)> a3) {
a3(a2);
}
int main(int, char **) {
TaskScheduler ns;
Test1 *test1Ptr = 0;
auto test2Sptr = std::make_shared<Test2>();
std::function<void(std::shared_ptr<Test2>)> callback =
[](std::shared_ptr<Test2>){
std::cout << "Hello from me " << std::endl;
};
ns.queue<TaskScheduler::Callback<std::shared_ptr<Test2>>, Test1 *,
std::shared_ptr<Test2>>(&function1, test1Ptr, test2Sptr, callback);
ns.fire();
}
I am getting following error,
test.cc:63:8: error: no matching member function for call to 'queue'
ns.queue<TaskScheduler::Callback<std::shared_ptr<Test2>>, Test1 *,
std::shared_ptr<Test2>>(&function1, test1Ptr, test2Sptr, callback);
~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.cc:17:10: note: candidate template ignored: failed template argument
deduction
void queue(void (*requestFunction)(TRequestParam..., typename
TCallback::Type),
^
1 error generated.</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>