summaryrefslogtreecommitdiff
path: root/userspace/cpp/testcpp.cpp
blob: 8ed7d55288ebffd28f7a33467f5cde1d03a77af1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <algorithm>
#include <vector>
#include <cstdio>
#include <iostream>


struct test
{
    int i;
    test(int ii):i(ii) { printf("test:ctor %i\n",i);  }
    ~test() { printf("test:dtor %i\n",i ); }
};

test t1(1); // global constructor should get called and desctructed on exit from our crt0

int somefunc()
{
    test t2(2);
}
int main()
{

    printf(" --- testing ctors & dtors ---\n");

    somefunc();
    test t3(3); 


    std::cout << "bye bye" << std::endl;

    /*

    int myints[] = {32,71,12,45,26,80,53,33};

    std::vector<int> myvector (myints, myints+8);               // 32 71 12 45 26 80 53 33
    std::sort (myvector.begin(), myvector.begin()+4);           //(12 32 45 71)26 80 53 33

    for (std::vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
        printf("%i\n",*it);  

    printf("hello\n");
    printf("hello\n");
    */
    printf("-- fin -- \n");

}

//    printf("reent struct size: %d bytes\n",sizeof(struct _reent));
  //  printf("reent pointer : 0x%08x\n",_impure_ptr);
    //printf("reent pointer : 0x%08x\n",_impure_ptr);
// constructing vectors
/*
#include <iostream>
#include <vector>
#include <cstring>
#include <reent.h>

//#undef _REENT_GLOBAL_STDIO_STREAMS 

int main()
{
    std::cout << "hi" << std::endl;
  _REENT_INIT_PTR(_impure_ptr);


    

      // constructors used in the same order as described above:
  std::vector<int> first;                                // empty vector of ints
  std::vector<int> second (4,100);                       // four ints with value 100
  std::vector<int> third (second.begin(),second.end());  // iterating through second
  std::vector<int> fourth (third);                       // a copy of third

  // the iterator constructor can also be used to construct from arrays:
  int myints[] = {16,2,77,29};
  std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );

  std::cout << "The contents of fifth are:";
  for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it)
    std::cout << ' ' << *it;
  std::cout << '\n';



    return 0;
}
*/