Created
April 16, 2017 00:55
-
-
Save exjam/47b743f2d09e52fd89e8fc1db7232214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct TestStructure2 | |
{ | |
be2_val<uint32_t> intMember; | |
be2_ptr<uint32_t> ptrMember; | |
be2_ptr<TestStructure2> ptrToStructMember; | |
}; | |
struct TestStructure | |
{ | |
be2_val<uint32_t> intMember; | |
be2_struct<TestStructure2> structMember; | |
be2_ptr<uint32_t> ptrMember; | |
be2_ptr<TestStructure2> ptrToStructMember; | |
be2_ptr<void> ptrToVoid; | |
be2_ptr<TestStructure> ptrToStructMember2; | |
be2_array<uint32_t, 100> arr; | |
be2_ptr<uint32_t> ptrToArray; | |
}; | |
int main(int, char**) | |
{ | |
virt_ptr<void> vv; | |
be2_val<virt_ptr<void>> bv; | |
auto avv = static_cast<virt_addr>(vv); // OK | |
auto abv = static_cast<virt_addr>(bv); // FAILS | |
if (!vv) { | |
} | |
if (vv && bv) { | |
} | |
virt_ptr<TestStructure> test; | |
test->intMember = 0u; // Assign value to be_val | |
// ERROR: test->intMember = TestStructure2 { }; // Assign wrong value type to be_val | |
test->structMember.intMember = 0u; // Assign value to be_struct member | |
test->ptrToStructMember2 = test; // Assign virt_ptr to be_ptr | |
be2_val<uint32_t> asdax = test->arr[3]; | |
virt_ptr<uint32_t> asdap = &test->arr[3]; | |
test->ptrMember = nullptr; // Assign nullptr to be_ptr | |
test->ptrMember = &test->structMember.intMember; // operator &be_val to virt_ptr | |
virt_ptr<void> testVoid { test }; | |
test->ptrToStructMember = nullptr; | |
test->ptrToStructMember = &test->structMember; // operator &be_struct to virt_ptr | |
test->ptrToArray = &test->arr; // operator &be_array to virt_ptr | |
// void * implicit cast | |
test->ptrToVoid = test->ptrToStructMember; | |
// ERROR: test->ptrToStructMember = test->ptrToVoid; | |
struct Test { int a; }; | |
virt_ptr<uint32_t> x; | |
be2_val<uint32_t> &a = *x; | |
*x = 0u; | |
be2_val<uint32_t> q; | |
be2_ptr<uint32_t> reg_save_area; | |
reg_save_area = &q; | |
virt_ptr<double> fpr_save_area = virt_cast<double>(reg_save_area); | |
virt_ptr<Test> y; | |
y[0].a; | |
Test &b = *y; | |
y->a; | |
virt_ptr<virt_ptr<Test>> z; | |
be2_val<virt_ptr<Test>> &c = *z; | |
(*z)->a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment