RCP_ForwardDeclUnitTests.cpp

Go to the documentation of this file.
00001 #include "Teuchos_RCP.hpp"
00002 #include "Teuchos_UnitTestHarness.hpp"
00003 
00004 
00005 /*
00006  * This test checks that you can use non-owning Teuchos::RCP with pointers to
00007  * types that are only forward declared and not defined.
00008  */
00009 
00010 namespace DummyNS {class UndefinedType;}
00011 
00012 namespace Teuchos {
00013 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(DummyNS::UndefinedType);
00014 } // namespace Teuchos
00015 
00016 
00017 namespace {
00018 
00019 
00020 using Teuchos::rcp;
00021 using Teuchos::rcpFromRef;
00022 using Teuchos::RCP;
00023 
00024 using DummyNS::UndefinedType;
00025 
00026 
00027 TEUCHOS_UNIT_TEST( RCP, ForwardDeclaredUndefined )
00028 {
00029   // This test ensures that you can declare a null RCP object to an undefined
00030   // type without trouble.
00031   RCP<UndefinedType> ut_rcp;
00032 }
00033 
00034 
00035 TEUCHOS_UNIT_TEST( RCP, ForwardDeclaredUndefined_rcp )
00036 {
00037   // This test ensures that you can set a pointer to an undefined type without
00038   // trouble.  Note that this has to be a non-owning RCP otherwise there will
00039   // be issues with the destructor call.
00040   UndefinedType *ut_ptr = 0;
00041   RCP<UndefinedType> ut_rcp = rcpFromRef(*ut_ptr);
00042   // NOTE: You have to use rcpFroRef(...) and not rcp(..., false) because
00043   // rcp(..., false) will use the DeallocDelete class that has a delete call
00044   // that the compiler will complain about.
00045 }
00046 
00047 
00048 } // namespace
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Tue Oct 20 10:13:59 2009 for Teuchos Package Browser (Single Doxygen Collection) by  doxygen 1.6.1