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 <system/boxable_traits.h>
10#include <type_traits>
11
12namespace System { namespace Constraints {
13
15template <class Base, class Derived>
16struct IsBaseOf : std::is_base_of<Base, Derived> {};
17
19template <class Base, class Derived>
20struct IsBaseOf<Base, SharedPtr<Derived>> : std::is_base_of<Base, Derived> {};
21
23template <class Base, class Derived>
24struct IsBaseOf<SharedPtr<Base>, SharedPtr<Derived>> : std::is_base_of<Base, Derived> {};
25
27template <typename T, typename = void>
28struct IsDefaultConstructibleTest : public std::false_type {};
29
31template <typename T>
32struct IsDefaultConstructibleTest<T, decltype(void(new (std::declval<T*>()) T()))> : public std::true_type {};
33
35template <typename T>
37
39template <typename T>
41
44template <typename T>
45struct IsCsPointer : std::false_type{};
46
49template <class T>
50struct IsCsPointer<SharedPtr<T> > : std::true_type {};
51
54template <class T>
55struct IsCsPointer<WeakPtr<T> > : std::true_type {};
56
58template <typename>
59struct IsStdTuple : std::false_type {};
60
62template <typename T>
63struct IsStdTuple<std::tuple<T>> : std::true_type {};
64
65}} // namespace System::Constrains
66
67
68namespace System {
69 class String;
70 class DateTime;
71 class TimeSpan;
72}
73
74namespace System { namespace Constraints {
76 template<> struct IsCsPointer<System::String> : std::true_type {};
78 template<> struct IsCsPointer<System::DateTime> : std::true_type {};
80 template<> struct IsCsPointer<System::TimeSpan> : std::true_type {};
81}}
82
83
84// for translate "where T: A"
86#define assert_is_base_of(Base, Derived) \
87 static_assert(System::Constraints::IsBaseOf<Base, Derived>::value || System::BoxedValueDetail::ImplementsInterface_v<Derived, Base>, "typename " #Derived " must be child of " #Base)
88
89// for translate "where T: new()"
91#define assert_is_constructable(T) \
92 static_assert(System::Constraints::IsDefaultConstructible<T>::value, "typename " #T " must be default-constructible")
93
94// for translate "where T: class"
96#define assert_is_cs_class(T) \
97 static_assert(System::Constraints::IsCsPointer<T>::value, \
98 "typename " #T " must be System::SharedPtr<> or 'force-valued' type")
99
100// for translate "where T: struct"
102#define assert_is_cs_struct(T) \
103 static_assert(!System::Constraints::IsCsPointer<T>::value, \
104 "typename " #T " must not be System::SharedPtr<> or 'force-valued' type")
105
106#endif // _aspose_system_constrains_h_
107
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:125
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:16
A template predicate that determines if the specified type is a pointer type. By default any type is ...
Definition: constraints.h:45
A template predicate that determines if type T is default constructible.
Definition: constraints.h:36
Implementation that checks whether type is default constructible or not.
Definition: constraints.h:28
A template predicate that determines if the specified type is a tuple type.
Definition: constraints.h:59