CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
constraints.h
1
3
4#ifndef _aspose_system_constrains_h_
5#define _aspose_system_constrains_h_
6
7#include <system/shared_ptr.h>
8#include <system/weak_ptr.h>
9#include <type_traits>
10
11namespace System { namespace Constraints {
12
14template <class Base, class Derived>
15struct IsBaseOf : std::is_base_of<Base, Derived> {};
16
18template <class Base, class Derived>
19struct IsBaseOf<Base, SharedPtr<Derived>> : std::is_base_of<Base, Derived> {};
20
22template <class Base, class Derived>
23struct IsBaseOf<SharedPtr<Base>, SharedPtr<Derived>> : std::is_base_of<Base, Derived> {};
24
26template <typename T, typename = void>
27struct IsDefaultConstructibleTest : public std::false_type {};
28
30template <typename T>
31struct IsDefaultConstructibleTest<T, decltype(void(new (std::declval<T*>()) T()))> : public std::true_type {};
32
34template <typename T>
36
38template <typename T>
40
43template <typename T>
44struct IsCsPointer : std::false_type{};
45
48template <class T>
49struct IsCsPointer<SharedPtr<T> > : std::true_type {};
50
53template <class T>
54struct IsCsPointer<WeakPtr<T> > : std::true_type {};
55
57template <typename>
58struct IsStdTuple : std::false_type {};
59
61template <typename T>
62struct IsStdTuple<std::tuple<T>> : std::true_type {};
63
64}} // namespace System::Constrains
65
66
67namespace System {
68 class String;
69 class DateTime;
70 class TimeSpan;
71}
72
73namespace System { namespace Constraints {
75 template<> struct IsCsPointer<System::String> : std::true_type {};
77 template<> struct IsCsPointer<System::DateTime> : std::true_type {};
79 template<> struct IsCsPointer<System::TimeSpan> : std::true_type {};
80}}
81
82
83// for translate "where T: A"
85#define assert_is_base_of(Base, Derived) \
86 static_assert(System::Constraints::IsBaseOf<Base, Derived>::value, "typename " #Derived " must be child of " #Base)
87
88// for translate "where T: new()"
90#define assert_is_constructable(T) \
91 static_assert(System::Constraints::IsDefaultConstructible<T>::value, "typename " #T " must be default-constructible")
92
93// for translate "where T: class"
95#define assert_is_cs_class(T) \
96 static_assert(System::Constraints::IsCsPointer<T>::value, \
97 "typename " #T " must be System::SharedPtr<> or 'force-valued' type")
98
99// for translate "where T: struct"
101#define assert_is_cs_struct(T) \
102 static_assert(!System::Constraints::IsCsPointer<T>::value, \
103 "typename " #T " must not be System::SharedPtr<> or 'force-valued' type")
104
105#endif // _aspose_system_constrains_h_
106
Represents a specific date and time value on the time continuum. This type should be allocated on sta...
Definition: date_time.h:50
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Represents a time interval. This type should be allocated on stack and passed to functions by value o...
Definition: timespan.h:59
Subclass of System::SmartPtr which sets itself to weak mode at construction. Please note that this cl...
Definition: weak_ptr.h:18
Definition: db_command.h:9
@ DateTime
A type representing a date and time value.
A template predicate that determines if type Derived is derived from Base.
Definition: constraints.h:15
A template predicate that determines if the specified type is a pointer type. By default any type is ...
Definition: constraints.h:44
A template predicate that determines if type T is default constructible.
Definition: constraints.h:35
Implementation that checks whether type is default constructible or not.
Definition: constraints.h:27
A template predicate that determines if the specified type is a tuple type.
Definition: constraints.h:58