Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

print_seq.h

Go to the documentation of this file.
00001 // Sequence output implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2003 Hermann Schichl
00004 //
00005 // This file is part of the COCONUT API.  This library
00006 // is free software; you can redistribute it and/or modify it under the
00007 // terms of the Library GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // Library GNU General Public License for more details.
00015 
00016 // As a special exception, you may use this file as part of a free software
00017 // library without restriction.  Specifically, if other files instantiate
00018 // templates or use macros or inline functions from this file, or you compile
00019 // this file and link it with other files to produce an executable, this
00020 // file does not by itself cause the resulting executable to be covered by
00021 // the Library GNU General Public License.  This exception does not however
00022 // invalidate any other reasons why the executable file might be covered by
00023 // the Library GNU General Public License.
00024 
00027 #ifndef __PRINT_SEQ_H_
00028 #define __PRINT_SEQ_H_
00029 
00030 #include <iostream>
00031 #include <vector>
00032 #include <list>
00033 #include <deque>
00034 #include <iterator>
00035 
00036 namespace std {
00037 
00038 template <class _Ve, class _A>
00039 std::ostream& std::operator<<(std::ostream& o, const std::vector<_Ve,_A>& a)
00040 {
00041   if(a.size() == 1)
00042     o << a[0];
00043   else if(!a.empty())
00044   {
00045     typename std::vector<_Ve,_A>::const_iterator e(a.end());
00046     std::copy(a.begin(), --e, std::ostream_iterator<_Ve>(o, ", "));
00047     o << *e;
00048   }
00049   return o;
00050 }
00051 
00052 template <class _Ve, class _A>
00053 std::ostream& std::operator<<(std::ostream& o, const std::list<_Ve,_A>& a)
00054 {
00055   if(a.size() == 1)
00056     o << a[0];
00057   else if(!a.empty())
00058   {
00059     typename std::list<_Ve,_A>::const_iterator e(a.end());
00060     std::copy(a.begin(), --e, std::ostream_iterator<_Ve>(o, ", "));
00061     o << *e;
00062   }
00063   return o;
00064 }
00065 
00066 template <class _Ve, class _A>
00067 std::ostream& std::operator<<(std::ostream& o, const std::deque<_Ve,_A>& a)
00068 {
00069   if(a.size() == 1)
00070     o << a[0];
00071   else if(!a.empty())
00072   {
00073     typename std::deque<_Ve,_A>::const_iterator e(a.end());
00074     std::copy(a.begin(), --e, std::ostream_iterator<_Ve>(o, ", "));
00075     o << *e;
00076   }
00077   return o;
00078 }
00079 
00080 } // namespace std
00081 
00082 #endif /* __PRINT_SEQ_H_ */

Generated on Tue Nov 4 01:57:58 2003 for COCONUT API by doxygen1.2.18