[llvm-bugs] [Bug 36773] New: compilation error while trying to deduce type from a struct which takes variadic paramter
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Mar 16 12:11:55 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=36773
Bug ID: 36773
Summary: compilation error while trying to deduce type from a
struct which takes variadic paramter
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: ranjith.tv at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180316/708a7184/attachment.html>
More information about the llvm-bugs
mailing list