0029151: GCC 7.1 warnings "this statement may fall through" [-Wimplicit-fallthrough=]
[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
19#include <Standard_Type.hxx>
20
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
46 template <typename T1>
47 NCollection_Shared (T1 arg1) : T(arg1) {}
48
49 //! Constructor with two arguments
50 template <typename T1, typename T2>
51 NCollection_Shared (T1 arg1, T2 arg2) : T(arg1, arg2) {}
52
53/* this could work...
54 //! Forwarding constructor
55 template<typename... Args>
56 NCollection_Shared (Args&&... args)
57 : T (std::forward<Args>(args)...)
58 {}
59*/
60};
61
62#endif