source: src/examples/wrapper/src/pointer.h @ 03286aa

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 03286aa was 03286aa, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

added tests ctor and dtor

  • Property mode set to 100644
File size: 763 bytes
Line 
1#pragma once
2
3#include <fstream>
4#include <stddef.h>
5#include <stdlib.h>
6
7struct content_t
8{
9        int value;
10        size_t count;
11};
12
13void ?{}(content_t* this)
14{
15        sout | "Constructing content" | endl;
16        this->count = 0;
17}
18
19void ^?{}(content_t* this)
20{
21        sout | "Destroying content" | endl;
22}
23
24// struct wrapper_t
25// {
26//      content_t* ptr;
27// };
28//
29// void ?{}(wrapper_t* this)
30// {
31//      //content_t** cp = &this->ptr;
32//      //*cp = malloc();
33//      this->ptr->count++;
34//      sout | "Constructing ref pointer" | endl;
35//      sout | "Reference is " | this->ptr->count | endl;
36// }
37//
38// void ^?{}(wrapper_t* this)
39// {
40//      this->ptr->count--;
41//      if(!this->ptr->count) free(this->ptr);
42//      sout | "Destroying ref pointer" | endl;
43//      sout | "Reference is " | this->ptr->count | endl;
44// }
Note: See TracBrowser for help on using the repository browser.