VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
polymorphic_pointer_downcast.h
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include <boost/shared_ptr.hpp>
8 
11 template <typename Derived, typename Base>
12 inline boost::shared_ptr<Derived> polymorphic_pointer_downcast(
13  const boost::shared_ptr<Base>& b)
14 {
15 #ifdef _DEBUG
16  boost::shared_ptr<Derived> d(boost::dynamic_pointer_cast<Derived>(b));
17  assert(d);
18  return d;
19 #else
20  return boost::static_pointer_cast<Derived>(b);
21 #endif
22 }
boost::shared_ptr< Derived > polymorphic_pointer_downcast(const boost::shared_ptr< Base > &b)
works like boost::polymorphic_downcast with boost::shared_ptr use when a cast should always work but ...
Definition: polymorphic_pointer_downcast.h:12

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)