我有这样的代码: Link to Wandbox
当我尝试编译它时,我得到了这个:
./type_holder.h:45:14: error: no matching constructor for initialization of 'test_class'
return new T(args...);
^ ~~~~
./type_holder.h:54:35: note: in instantiation of member function 'di::DiConstructor<true, test_class, di::DiMark &&, di::AnyResolver>::construct' requested
here
decltype(AnyResolver())>::construct(std::move(DiMark{}), AnyResolver{});
^
test.cc:26:19: note: in instantiation of function template specialization 'di::ConstructIfPossible<test_class>' requested here
std::cout << di::ConstructIfPossible<test_class>() << std::endl;
^
test.cc:14:9: note: candidate constructor not viable: no known conversion from 'di::DiMark' to 'di::DiMark &&' for 1st argument
INJECT(test_class, int* a) {}
^
./inject_markers.h:6:36: note: expanded from macro 'INJECT'
#define INJECT(name, ...) explicit name(di::DiMark&& m, __VA_ARGS__)
^
test.cc:12:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class test_class {
^
test.cc:12:7: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
1 error generated.
问题是我做错了什么?为什么编译器告诉我我正在尝试转换DiMark
为DiMark&&
?DiMark&&
自从我std::move(DiMark) {}
明确地将左值转换为右值后,它应该不是已经存在了吗?