1 // Created on: 2019-03-27
2 // Created by: Timur Izmaylov
3 // Copyright (c) 2019 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Standard_Std_HeaderFile
17 #define _Standard_Std_HeaderFile
20 #include <type_traits>
23 //! Namespace opencascade is intended for low-level template classes and functions
27 //! Namespace opencascade::std includes templates from C++11 std namespace used by
28 //! OCCT classes. These definitions are imported from std namespace, plus (on older
29 //! compilers) from std::tr1, or implemented by custom code where neither std
30 //! not std::tr1 provide necessary definitions.
33 // import all available standard stuff from std namespace
34 using namespace ::std;
36 // for old MSVC compiler, some standard templates are defined in std::tr1 namespace,
37 // and some missing ones are implemented here
38 #if (defined(_MSC_VER) && (_MSC_VER < 1600))
39 using namespace ::std::tr1;
41 // C++11 template class enable_if
42 template <bool Test, class Type = void>
44 { // type is undefined for assumed !_Test
47 template <class _Type>
48 struct enable_if<true, _Type>
49 { // type is _Type for _Test
53 template <bool Condition, typename TypeTrue, typename TypeFalse>
56 typedef TypeTrue type;
59 template <typename TypeTrue, typename TypeFalse>
60 struct conditional<false, TypeTrue, TypeFalse>
62 typedef TypeFalse type;
69 //! Trait yielding true if class T1 is base of T2 but not the same
70 template <class T1, class T2, class Dummy = void>
71 struct is_base_but_not_same : opencascade::std::is_base_of<T1, T2>
75 //! Explicit specialization of is_base_of trait to workaround the
76 //! requirement of type to be complete when T1 and T2 are the same.
77 template <class T1, class T2>
78 struct is_base_but_not_same<T1,
80 typename opencascade::std::enable_if<opencascade::std::is_same<T1, T2>::value>::type>
81 : opencascade::std::false_type
85 //! The type trait that checks if the passed type is integer (it must be integral and not boolean)
86 //! @tparam TheInteger the checked type
87 template <typename TheInteger>
88 struct is_integer : std::integral_constant<bool,
89 opencascade::std::is_integral<TheInteger>::value
90 && !opencascade::std::is_same<TheInteger, bool>::value>
94 //! The auxiliary template that is used for template argument deduction in function templates. A function argument
95 //! which type is a template type parameter and it is not needed to be deducted must be declared using this class
96 //! template based on the type of some other template type parameter of a function template
97 //! @tparam TheType the type that is used as a function argument type to prevent its deduction
98 template <typename TheType>
99 struct disable_deduction
101 typedef TheType type;
104 } // namespace opencascade