0030569: Foundation Classes - NCollection_Shared lacks inclusion of NCollection_Defin...
[occt.git] / src / NCollection / NCollection_Shared.hxx
CommitLineData
e7195ab4 1// Created on: 2015-06-26
2// Created by: Andrey Betenev
3// Copyright (c) 2015 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef NCollection_Shared_HeaderFile
17#define NCollection_Shared_HeaderFile
18
d65f9183 19#include <NCollection_DefineAlloc.hxx>
20
e7195ab4 21//! Template defining a class derived from the specified base class and
22//! Standard_Transient, and supporting OCCT RTTI.
23//!
24//! This provides possibility to use Handes for types not initially intended
25//! to be dynamically allocated.
26//!
27//! Current limitation is that only copy and constructors with 1-3 arguments are defined,
28//! calling those of the argument class (default constructor must be available).
29//! It can be improved when perfect forwarding of template arguments is supported
30//! by all compilers used for OCCT.
31//!
32//! The intent is similar to std::make_shared<> in STL, except that this
33//! implementation defines a separate type.
34
71c810df 35template <class T, typename = typename opencascade::std::enable_if<! opencascade::std::is_base_of<Standard_Transient, T>::value>::type>
e7195ab4 36class NCollection_Shared : public Standard_Transient, public T
37{
38public:
39 DEFINE_STANDARD_ALLOC
40 DEFINE_NCOLLECTION_ALLOC
41
42 //! Default constructor
43 NCollection_Shared () {}
44
45 //! Constructor with single argument
45117bfc 46 template<typename T1> NCollection_Shared (const T1& arg1) : T(arg1) {}
47
48 //! Constructor with single argument
49 template<typename T1> NCollection_Shared (T1& arg1) : T(arg1) {}
50
51 //! Constructor with two arguments
52 template<typename T1, typename T2> NCollection_Shared (const T1& arg1, const T2& arg2) : T(arg1, arg2) {}
53
54 //! Constructor with two arguments
55 template<typename T1, typename T2> NCollection_Shared (T1& arg1, const T2& arg2) : T(arg1, arg2) {}
56
57 //! Constructor with two arguments
58 template<typename T1, typename T2> NCollection_Shared (const T1& arg1, T2& arg2) : T(arg1, arg2) {}
e7195ab4 59
60 //! Constructor with two arguments
45117bfc 61 template<typename T1, typename T2> NCollection_Shared (T1& arg1, T2& arg2) : T(arg1, arg2) {}
e7195ab4 62
63/* this could work...
64 //! Forwarding constructor
65 template<typename... Args>
66 NCollection_Shared (Args&&... args)
67 : T (std::forward<Args>(args)...)
68 {}
69*/
70};
71
72#endif