and click on:
A: There are two ways to get at the underlying raw pointer to an object that is wrapped in the RefCountPtr<C> object
C *c_rptr1 = c_ptr.get(); // Unchecked, can be NULL C *c_rptr2 = &*c_ptr; // Checked in debug build and will not return NULL
You should use
c_ptr.get() when it is okay for the pointer to be
NULL. On the other hand, you should use
&*c_ptr when you don't want to allow the raw pointer to be
NULL. This is because the operator function <tt>Teuchos::RefCountPtr::operator*() will throw an exception if
Teuchos::RefCountPtr::get()==NULL when the code is compiled using the macro define
For more information see Item 3 in Appendix B in
For more information see the main body and Appendix D of the document:
A: Generally member functions should only be used over non-member functions when direct access to private or protected data for functions is required. By minimizing the amount of code that can access non-public data you greatly simplify maintenance. See section 11.3.1 in "The C++ Programming Language: Special Edition" for a discussion of this topic.
Thyra::sillyPowerMethod() examples for how this templating is used.
A: You must use the non-member functions
Thyra::createMembers() described here.