File: main.cc

package info (click to toggle)
aspectc%2B%2B 1.0pre4~svn.20080711-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 104,504 kB
  • ctags: 363,975
  • sloc: cpp: 1,645,814; ansic: 16,601; sh: 2,175; makefile: 1,043
file content (81 lines) | stat: -rw-r--r-- 1,718 bytes parent folder | download | duplicates (12)
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
#include <stdio.h>

// case 1: call and function in the same namespace
namespace N1 {

  int foo() {
    return 1;
  }

  const int var = foo();
}

// case 2: call outside the namespace, function inside
namespace N2 {

  int foo() {
    return 1;
  }
}

int var2_1 = N2::foo(), var2_2 = N2::foo ();

// case 3: call inside the namespace, function outside
int bar() { return 42; }

namespace N3 {
  int var = ::bar();
}

// case 4: static attribute initialization
class Test {
public:
  static int var;
};

int Test::var = bar ();

// case 5: static attribute initialization in a namespace
namespace N3 {
  class Test {
  public:
    static int var;
  };

  int Test::var = bar ();
}

// case 6: static attribute initialization of class in namespace
namespace N4 {
  class Test {
  public:
    static int var;
  };
}

int N4::Test::var = bar ();

// case 7: a call in an initializer list
class WithInitializer {
  int attr;
public:
  WithInitializer () : attr (bar ()) {}
  WithInitializer (int);
};

WithInitializer::WithInitializer (int v) : attr (v + bar ()) {}

int main() {
  printf ("StandAloneCalls:\n");
  printf ("===============================================================\n");
  printf ("here starts main, but we should have seen our advice already\n");
  printf ("global var 1 = %d\n", N1::var);
  printf ("global var 2-1 = %d, 2-2 = %d\n", var2_1, var2_2);
  printf ("global var 3 = %d\n", N3::var);
  printf ("---------------------------------------------------------------\n");
  printf ("Now the advice for calls in constructor init lists is checked\n");
  WithInitializer wi1;
  WithInitializer wi2 (3);
  printf ("---------------------------------------------------------------\n");
  return 0;
}