static_pointer_cast not declared in this scope

T

Tim H

help?!?

#include <boost/shared_ptr.hpp>
class pp_dirent {};
class pp_scope: public pp_dirent {};

int main() {
boost::shared_ptr<pp_dirent> p1(new pp_scope());
boost::shared_ptr<pp_scope> p2 =
static_pointer_cast<pp_scope>(p1);
return 0;
}


g++ test.cpp -o test
test.cpp: In function int main():
test.cpp:8: error: static_pointer_cast was not declared in this scope
test.cpp:8: error: expected primary-expression before > token


What?
 
A

Alf P. Steinbach

* Tim H:
help?!?

#include <boost/shared_ptr.hpp>
class pp_dirent {};
class pp_scope: public pp_dirent {};

int main() {
boost::shared_ptr<pp_dirent> p1(new pp_scope());
boost::shared_ptr<pp_scope> p2 =
static_pointer_cast<pp_scope>(p1);
return 0;
}


g++ test.cpp -o test
test.cpp: In function int main():

You have an error in function 'main'.

test.cpp:8: error: static_pointer_cast was not declared in this scope

It was that 'static_pointer' was not used but haven't been declared.
Perhaps you meant something like 'boost::static_pointer_cast'.

test.cpp:8: error: expected primary-expression before > token

And at the point of detecting that, the compiler had parsed your code as
far as the latest '>' token on line 8, where it expected a primary
expression, not some undeclared name.


What what?

Just read the compiler's diagnostic messages.
 
A

Alf P. Steinbach

* Alf P. Steinbach:
It was that 'static_pointer' was not used but haven't been declared.

Corrected typos:
It was that 'static_pointer' was used but hasn't been declared.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top