0

I'm trying to cast std::shared_ptr<Node> to std::shared_ptr<Node3D>

auto node3d = static_cast<std::shared_ptr<Node3D>>(node);

I got an error:

E0312 no suitable user-defined conversion from "std::shared_ptr<Node>" to "std::shared_ptr<Node3D>" exists

Evg
  • 25,259
  • 5
  • 41
  • 83
Blaze
  • 813
  • 2
  • 8
  • 13
  • 3
    You'd improve your question by far if you gave more context, like a [mcve]. In particular, the relation between `Node` and `Node3D` is missing. – Ulrich Eckhardt Aug 03 '21 at 20:08
  • This is sort of a duplicate but the title uses downcast which thwarts folks finding it. – wcochran Aug 03 '21 at 20:13

1 Answers1

2

Try std::static_pointer_cast

std::static_pointer_cast<Node3D>(node)
Blaze
  • 813
  • 2
  • 8
  • 13