Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename T>
- using MyTuple = std::tuple<int, MyData, T>;
- std::unique_ptr<std::priority_queue<MyTuple<MyTypeA>,
- std::vector<MyTuple<MyTypeA>>,
- Compare<MyTuple<MyTypeA>>>> pqueue1;
- std::unique_ptr<std::priority_queue<MyTuple<MyTypeB>,
- std::vector<MyTuple<MyTypeB>>,
- Compare<MyTuple<MyTypeB>>>> pqueue2;
- // MyTypeA and MyTypeB are structs
- class Tester
- {
- public:
- template <typename T>
- void Tester::add_to_queue(T &typ)
- {
- int status;
- T myType = typ;
- char *cname = abi::__cxa_demangle(typeid(myType).name(), 0, 0, &status);
- string ctype(cname);
- int lvl = 1;
- MyData data;
- MyTuple<P> t(lvl, data, myType);
- if (ctype.compare("MyTypeA") == 0)
- {
- pqueue1->push(std::make_tuple(lvl, data, itemType));
- } else if (ctype.compare("MyTypeB") == 0)
- {
- int lvl = 2;
- MyData data;
- pqueue2->push(std::make_tuple(lvl, data, itemType));
- }
- }
- };
- // In fileA.cpp I have ...
- DataTypeA dta;
- // ...
- mgr->add_to_queue<DataTypeA>(dta);
- // And in fileB.cpp, I have ...
- DataTypeB dtb;
- // ...
- mgr->add_to_queue<DataTypeB>(dtb);
- /*
- When I compile this, I get the following error ...
- Tester.h:63:3: error: no matching function for call to ‘std::priority_queue<std::tuple<int, MyData, DataTypeB>, std::vector<std::tuple<int, MyData, DataTypeB> >, Compare<std::tuple<int, MyData, DataTypeB> > >::push(std::tuple<int, MyData, DataTypeA>)’
- pqueue2->push(std::make_tuple(lvl, data, itemType));
- ^
- fileA.cpp:5:
- /usr/include/c++/5/bits/stl_queue.h:499:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, MyData, DataTypeB>; _Sequence = std::vector<std::tuple<int, MyData, DataTypeB> >; _Compare = Compare<std::tuple<int, MyData, DataTypeB> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, MyData, DataTypeB>]
- push(const value_type& __x)
- ^
- /usr/include/c++/5/bits/stl_queue.h:499:7: note: no known conversion for argument 1 from ‘std::tuple<int, MyData, DataTypeA>’ to ‘const value_type& {aka const std::tuple<int, MyData, DataTypeB>&}’
- /usr/include/c++/5/bits/stl_queue.h:507:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, MyData, DataTypeB>; _Sequence = std::vector<std::tuple<int, MyData, DataTypeB> >; _Compare = Compare<std::tuple<int, MyData, DataTypeB> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, MyData, DataTypeB>]
- push(value_type&& __x)
- ^
- /usr/include/c++/5/bits/stl_queue.h:507:7: note: no known conversion for argument 1 from ‘std::tuple<int, MyData, DataTypeA>’ to ‘std::priority_queue<std::tuple<int, MyData, DataTypeB>, std::vector<std::tuple<int, MyData, DataTypeB> >, Compare<std::tuple<int, MyData, DataTypeB> > >::value_type&& {aka std::tuple<int, MyData, DataTypeB>&&}’
- */
Advertisement
Add Comment
Please, Sign In to add comment