Commit | Line | Data |
---|---|---|
a4100ebe CY |
1 | // testtypedefs.cpp --- Sample with some fake bits out of std::string |
2 | ||
73b0cd50 | 3 | // Copyright (C) 2008-2011 Free Software Foundation, Inc. |
a4100ebe CY |
4 | |
5 | // Author: Eric M. Ludlam <eric@siege-engine.com> | |
6 | ||
7 | // This file is part of GNU Emacs. | |
8 | ||
9 | // GNU Emacs is free software: you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation, either version 3 of the License, or | |
12 | // (at your option) any later version. | |
13 | ||
14 | // GNU Emacs is distributed in the hope that it will be useful, | |
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | // GNU General Public License for more details. | |
18 | ||
19 | // You should have received a copy of the GNU General Public License | |
20 | // along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
21 | ||
74ea13c1 CY |
22 | // Thanks Ming-Wei Chang for these examples. |
23 | ||
24 | namespace std { | |
74ea13c1 | 25 | template <T>class basic_string { |
74ea13c1 CY |
26 | public: |
27 | void resize(int); | |
74ea13c1 | 28 | }; |
74ea13c1 CY |
29 | } |
30 | ||
31 | typedef std::basic_string<char> mstring; | |
32 | ||
33 | using namespace std; | |
34 | typedef basic_string<char> bstring; | |
35 | ||
74ea13c1 CY |
36 | int main(){ |
37 | mstring a; | |
74ea13c1 CY |
38 | a.// -1- |
39 | ; | |
40 | // #1# ( "resize" ) | |
74ea13c1 CY |
41 | bstring b; |
42 | // It doesn't work here. | |
43 | b.// -2- | |
44 | ; | |
45 | // #2# ( "resize" ) | |
74ea13c1 CY |
46 | return 0; |
47 | } | |
48 | ||
74ea13c1 CY |
49 | // ------------------ |
50 | ||
a4100ebe | 51 | class Bar |
74ea13c1 CY |
52 | { |
53 | public: | |
54 | void someFunc() {} | |
74ea13c1 CY |
55 | }; |
56 | ||
57 | typedef Bar new_Bar; | |
58 | ||
59 | template <class mytype> | |
a4100ebe | 60 | class TBar |
74ea13c1 CY |
61 | { |
62 | public: | |
63 | void otherFunc() {} | |
74ea13c1 CY |
64 | }; |
65 | ||
66 | typedef TBar<char> new_TBar; | |
67 | ||
68 | int main() | |
69 | { | |
70 | new_Bar nb; | |
71 | new_TBar ntb; | |
72 | ||
73 | nb.// -3- | |
74 | ; | |
75 | // #3# ("someFunc") | |
74ea13c1 CY |
76 | ntb.// -4- |
77 | ; | |
78 | // #4# ("otherFunc") | |
74ea13c1 CY |
79 | return 0; |
80 | } | |
3999968a | 81 |