Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:20

0001 // Created on: 2015-06-26
0002 // Created by: Andrey Betenev
0003 // Copyright (c) 2015 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef NCollection_Shared_HeaderFile
0017 #define NCollection_Shared_HeaderFile
0018 
0019 #include <NCollection_DefineAlloc.hxx>
0020 
0021 //! Template defining a class derived from the specified base class and 
0022 //! Standard_Transient, and supporting OCCT RTTI.
0023 //!
0024 //! This provides possibility to use Handes for types not initially intended
0025 //! to be dynamically allocated.
0026 //!
0027 //! Current limitation is that only copy and constructors with 1-3 arguments are defined,
0028 //! calling those of the argument class (default constructor must be available).
0029 //! It can be improved when perfect forwarding of template arguments is supported
0030 //! by all compilers used for OCCT.
0031 //!
0032 //! The intent is similar to std::make_shared<> in STL, except that this
0033 //! implementation defines a separate type.
0034 
0035 template <class T, typename = typename opencascade::std::enable_if<! opencascade::std::is_base_of<Standard_Transient, T>::value>::type>
0036 class NCollection_Shared : public Standard_Transient, public T
0037 {
0038 public:
0039   DEFINE_STANDARD_ALLOC
0040   DEFINE_NCOLLECTION_ALLOC
0041 
0042   //! Default constructor
0043   NCollection_Shared () {}
0044 
0045   //! Constructor with single argument
0046   template<typename T1> NCollection_Shared (const T1& arg1) : T(arg1) {}
0047 
0048   //! Constructor with single argument
0049   template<typename T1> NCollection_Shared (T1& arg1) : T(arg1) {}
0050 
0051   //! Constructor with two arguments
0052   template<typename T1, typename T2> NCollection_Shared (const T1& arg1, const T2& arg2) : T(arg1, arg2) {}
0053 
0054   //! Constructor with two arguments
0055   template<typename T1, typename T2> NCollection_Shared (T1& arg1, const T2& arg2) : T(arg1, arg2) {}
0056 
0057   //! Constructor with two arguments
0058   template<typename T1, typename T2> NCollection_Shared (const T1& arg1, T2& arg2) : T(arg1, arg2) {}
0059 
0060   //! Constructor with two arguments
0061   template<typename T1, typename T2> NCollection_Shared (T1& arg1, T2& arg2) : T(arg1, arg2) {}
0062 
0063 /* this could work...
0064   //! Forwarding constructor
0065   template<typename... Args>
0066   NCollection_Shared (Args&&... args) 
0067   : T (std::forward<Args>(args)...)
0068   {}
0069 */
0070 };
0071 
0072 #endif