testtypedefs.cpp 1.5 KB

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