Skip to content

Commit

Permalink
Merge pull request #770 from nseam/v3.009-dev--cpp-compatibility-table
Browse files Browse the repository at this point in the history
Updated c++ compatibility table.
  • Loading branch information
kenorb authored Sep 10, 2024
2 parents 4692e26 + 6c09de3 commit 5914168
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,36 @@ For example, to format file inplace, run:

To improve code compatibility, please use the following syntax:

| MQL | C++ | Syntax to use |
|:------------------|:------------------------|:---------------------------|
| `&this` | `this` | `THIS_PTR` |
| `GetPointer(obj)` | `*obj` | `GET_PTR(obj)` |
| `Ref<X>.Ptr().a` | `Ref<X>.Ptr()->a` | `Ref<X> REF_DEREF a` |
| `T name[]` | `_cpp_array<T> name` | `ARRAY(T, name)` |
| `T<A, B> N[]` | `_cpp_array<T<A, B>> N` | `ARRAY(T<A, B>, N)` |
| `long` | `long long` | `int64` |
| `obj.Method()` | `obj->Method()` | `obj PTR_DEREF Method()` |
| `obj.a1.a2` | `obj->a1->a2` | `PTR_ATTRIB2(obj, a1, a2)` |
| `obj.attr` | `obj->attr` | `PTR_ATTRIB(obj, attr)` |
| `str == NULL` | `str == NULL` | `IsNull(str)` |
| MQL | C++ | Syntax to use |
|:-------------------|:-------------------------|:---------------------------|
| `&this` | `this` | `THIS_PTR` |
| `this` | `*this` | `THIS_REF` |
| `GetPointer(obj)` | `&obj` | `GET_PTR(obj)` |
| `T name[]` | `std::vector<T> name` | `ARRAY(T, name)` |
| `T name[5]` | `T name[5]` | `FIXED_ARRAY(T, name, 5)` |
| `X f(T[] v)` [ ]=5| `X f(T(&n)[5])` | `FIXED_ARRAY_REF(T, n, 5)` |
| `T<A, B> name[]` | `vector<T<A, B>> name` | `ARRAY(T<A, B>, N)` |
| `long` | `long long` | `int64` |
| `unsigned long` | `unsigned long long` | `uint64` |
| `obj.Method()` *1| `obj->Method()` | `obj PTR_DEREF Method()` |
| `obj.Ptr().a` *3| `obj.Ptr()->a` | `obj REF_DEREF a` |
| `obj.a1.a2` *1| `obj->a1->a2` | `PTR_ATTRIB2(obj, a1, a2)` |
| `obj.attr` *1| `obj->attr` | `PTR_ATTRIB(obj, attr)` |
| `str == NULL` | `str == NULL` | `IsNull(str)` |
| `foo((Ba&)obj)` *2| `foo(*obj)` | `foo(PTR_TO_REF(obj))` |
| `foo((Ba*)obj)` *1| `foo(&obj)` | `foo(REF_TO_PTR(obj))` |
| `void* N` *4| `void*& N[]` | `VOID_DATA(N)` |
| `int foo` *5| `const int foo` | `CONST_CPP int foo` |
| `int foo(int v)` *5| `int foo(int& v)` | `int foo(int REF_CPP v)` |
| `X foo()` *5| `X& foo()` | `X REF_CPP foo()` |
| `obj == NULL` *1| `obj == nullptr` | `obj == nullptr` |
| `datetime d = NULL`| `datetime d = 0` | `datetime = 0` |

**\*1** - Only if `obj` is a pointer.
**\*2** - Only if `obj` is an object or reference type (e.g., `Foo &`).
**\*3** - Only if `obj` is `Ref<X>`.
**\*4** - Only when used as a parameter to function.
**\*5** - In C++ we could want to return structure by reference or add `const` to the variable or result.

## Proposing changes

Expand Down

0 comments on commit 5914168

Please sign in to comment.