-
September 15th, 2015, 10:03 PM
#1
error C3203: 'set' : unspecialized class template can't be used as a template
I have tried both const QuadNode* and const QuadNode& to no avail.
Thanks
Jack
Code:
std::map<std::string, std::set<QuadNode*, QuadNodeSortedComparator>> activePool;
struct QuadNodeSortedComparator
{
bool operator()(const QuadNode& node1, const QuadNode& node2) const {
return std::tie(node1.x, node1.z) < std::tie(node2.x, node2.z);
}
};
-
September 16th, 2015, 12:29 AM
#2
Re: error C3203: 'set' : unspecialized class template can't be used as a template
Since the set is holding pointers I think you should access the members by ->, like node1->x rather than node1.x.
Last edited by tiliavirga; September 16th, 2015 at 02:05 AM.
-
September 16th, 2015, 02:33 AM
#3
Re: error C3203: 'set' : unspecialized class template can't be used as a template
Originally Posted by lucky6969b
I have tried both const QuadNode* and const QuadNode& to no avail.
Thanks
Jack
Code:
std::map<std::string, std::set<QuadNode*, QuadNodeSortedComparator>> activePool;
struct QuadNodeSortedComparator
{
bool operator()(const QuadNode& node1, const QuadNode& node2) const {
return std::tie(node1.x, node1.z) < std::tie(node2.x, node2.z);
}
};
Please provide the actual code that you used to produce the error. You just provided a snipet, and all it would produce is "error: 'QuadNodeSortedComparator' was not declared in this scope".
Appart from the fact that you are using a function that takes "const QuadNode&" to compare "QuadNode*" objects, I see nothing wrong with the code, provided you use the correct forward declarations etc.
But the devil is in the details:
- What is your "QuadNode" definition?
- What are your includes?
- What and where are your forward declarations?
Please provide a short but *complete* example that reproduces your issue.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
September 16th, 2015, 03:11 AM
#4
Re: error C3203: 'set' : unspecialized class template can't be used as a template
Hello, I change it back to QuadNode instead of QuadNode*, everything works great now.
Thanks for helping
Jack
-
September 16th, 2015, 03:33 AM
#5
Re: error C3203: 'set' : unspecialized class template can't be used as a template
Originally Posted by lucky6969b
I change it back to QuadNode instead of QuadNode*, everything works great now.
And the reason for that is that the set now holds QuadNode objects rather than QuadNode pointers. In the first case it's okay to access QuadNode members using . whereas in the second case you must use -> instead. Also in the second case it's kind of overkill to pass in the pointers by const reference to the () operator.
Last edited by tiliavirga; September 16th, 2015 at 04:12 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|