// @HEADER // ***************************************************************************** // Rapid Optimization Library (ROL) Package // // Copyright 2014 NTESS and the ROL contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #pragma once #include #include /* \file ROL_Ptr.hpp * \brief Provides unified interface Teuchos::RCP for legacy support. * ROL will be build with this implementation by default * unless ROL_ENABLE_STD_SHARED_PTR:BOOL=ON */ #include #include #include "Teuchos_RCP.hpp" namespace ROL { template using Ptr = Teuchos::RCP; static const Teuchos::ENull nullPtr = Teuchos::null; } namespace ROL { // Special case handling until C++14 (auto type deduction) is required // because template type deduction does not work for initializer_list here. template inline Ptr makePtr( std::initializer_list&& u ) { return Teuchos::rcp( new T(std::forward>(u)) ); } template inline Ptr makePtr( Args&&... args ) { return Teuchos::rcp( new T(std::forward(args)...) ); } template inline Ptr makePtrFromRef( T& obj ) { return Teuchos::rcpFromRef(obj); } template inline Ptr staticPtrCast( const Ptr& r ) noexcept { return Teuchos::rcp_static_cast(r); } template< class T, class U > inline Ptr constPtrCast( const Ptr& r ) noexcept { return Teuchos::rcp_const_cast(r); } template< class T, class U > inline Ptr dynamicPtrCast( const Ptr& r ) noexcept { return Teuchos::rcp_dynamic_cast(r); } template inline const T* getRawPtr( const Ptr& x ) { return x.get(); } template inline T* getRawPtr( const Ptr& x ) { return x.get(); } template inline int getCount( const Ptr& x ) { return x.strong_count(); } template inline bool is_nullPtr( const Ptr& x ) { return x.is_null(); } template inline Ptr toPtr( const Ptr& ptr ) { return ptr; } template inline Ptr toPtr( const Ptr& ptr ) { return ptr; } template struct IsSharedPtr : public std::false_type {}; template struct IsSharedPtr> : public std::true_type {}; } // namespace ROL