diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2003-07-09 00:40:29 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2003-07-09 00:40:29 +0000 |
commit | 9e7facfd47ed8da719ee0693ffb170e5d3d21379 (patch) | |
tree | 6ee20f1e724aa7748d12bae16ce110123b65f891 /libstdc++-v3/testsuite/ext | |
parent | 11597bc9695394e49ccedab270213c8cb7199c65 (diff) | |
download | gcc-9e7facfd47ed8da719ee0693ffb170e5d3d21379.zip gcc-9e7facfd47ed8da719ee0693ffb170e5d3d21379.tar.gz gcc-9e7facfd47ed8da719ee0693ffb170e5d3d21379.tar.bz2 |
pod_char_traits.cc: New.
2003-07-08 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/ext/pod_char_traits.cc: New.
* include/ext/pod_char_traits.h: New.
* include/Makefile.am (ext_headers): Add pod_char_traits.h.
* include/Makefile.in: Regenerate.
* docs/html/21_strings/howto.html: Update.
From-SVN: r69115
Diffstat (limited to 'libstdc++-v3/testsuite/ext')
-rw-r--r-- | libstdc++-v3/testsuite/ext/pod_char_traits.cc | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/ext/pod_char_traits.cc b/libstdc++-v3/testsuite/ext/pod_char_traits.cc new file mode 100644 index 0000000..c3c4eee --- /dev/null +++ b/libstdc++-v3/testsuite/ext/pod_char_traits.cc @@ -0,0 +1,78 @@ +// POD character, std::char_traits specialization -*- C++ -*- + +// Copyright (C) 2002, 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// Gabriel Dos Reis <gdr@integrable-solutions.net> +// Benjamin Kosnik <bkoz@redhat.com> + +#include <ext/pod_char_traits.h> + +int main() +{ + using namespace std; + using namespace __gnu_cxx; + + typedef unsigned short value_type; + typedef unsigned int int_type; + typedef character<value_type, int_type> char_type; + typedef char_traits<char_type> traits_type; + + bool test = true; + + // 1 char_type <-> value_type conversions + value_type uc1 = 'c'; + value_type uc2 = 'd'; + char_type c1 = { uc1 }; + char_type c2 = { uc2 }; + test = !(c1 == c2); + + // 2 char_traits + test = traits_type::eq(c1, c2); + + // 3 basic_string<char_type> + typedef basic_string<char_type> string_type; + string_type str; + char_type c3 = { value_type('b') }; + char_type c4 = { value_type('o') }; + char_type c5 = { value_type('r') }; + char_type c6 = { value_type('a') }; + char_type c7 = { value_type('c') }; + char_type c8 = { value_type('a') }; + char_type c9 = { value_type('y') }; + str += c3; + str += c4; + str += c5; + str += c6; + str += c7; + str += c8; + str += c9; + string_type::size_type len = str.size(); + const char_type* arr = str.c_str(); + + return 0; +} |