comparison test/cedet/tests/teststruct.cpp @ 104494:e480034314ce

Add Semantic unit tests.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 20 Sep 2009 04:00:13 +0000
parents
children 7f4c7f5c0eba
comparison
equal deleted inserted replaced
104493:a4e1a12c8b97 104494:e480034314ce
1 // Combinations of templates and structure inheritance.
2 //
3 // Created by Alex Ott.
4
5 template <typename DerivedT>
6 struct grammar {
7 public:
8 typedef grammar<DerivedT> self_t;
9 typedef DerivedT const& embed_t;
10 grammar() {}
11 ~grammar() { }
12 void use_parser() const { }
13 void test1() { }
14 };
15
16 struct PDFbool_parser : public grammar<PDFbool_parser> {
17 PDFbool_parser() {}
18 template <typename scannerT> struct definition {
19 typedef typename scannerT::iterator_t iterator_t;
20 int top;
21 definition(const PDFbool_parser& /*self*/) {
22 return ;
23 }
24 const int start() const {
25 return top;
26 }
27 };
28 };
29
30 int main(void) {
31 PDFbool_parser PDFbool_p = PDFbool_parser();
32 PDFbool_p.//-1-
33 ;
34 // #1# ("definition" "embed_t" "self_t" "test1" "use_parser")
35 }
36
37 // ----------------------------------------------------------------------
38
39 template <class Derived> struct Base {
40 public:
41 void interface()
42 {
43 // ...
44 static_cast<Derived*>(this)->implementation();
45 // ...
46 }
47
48 static void static_func()
49 {
50 // ...
51 Derived::static_sub_func();
52 // ...
53 }
54 };
55
56 struct Derived : Base<Derived> {
57 void implementation() { }
58 static void static_sub_func() { }
59 };
60
61 int foo () {
62 Derived d;
63 d.//-2-
64 ;
65 // #2# ("implementation" "interface" "static_func" "static_sub_func")
66 }