bump to -rc12
[gnucap-felix.git] / src / l_stlextra.h
blob3bf8d215efa88965e680c925e2e831a4d5626c6b
1 /*$Id: l_stlextra.h,v 1.1 2009-10-23 12:01:45 felix Exp $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *------------------------------------------------------------------
22 * extra functions in the STL style
23 * Things that ought to be there, but are not
25 //testing=script,complete 2006.07.13
26 #ifndef L_STLEXTRA_H
27 #define L_STLEXTRA_H
28 #include "md.h"
29 /*--------------------------------------------------------------------------*/
30 namespace notstd {
31 /*--------------------------------------------------------------------------*/
32 template <class InputIter, class Size, class OutputIter>
33 void copy_n(InputIter first, Size count, OutputIter result)
35 for ( ; count > 0; --count) {
36 *result++ = *first++;
39 /*--------------------------------------------------------------------------*/
40 /* find_ptr: like the stl find, except that the list contains pointers
41 Dereference the pointer in the list, then compare */
42 template <class InputIterator, class T>
43 InputIterator find_ptr(InputIterator first,InputIterator last,const T& value)
45 while (first != last && **first != value) {
46 ++first;
48 return first;
50 /*--------------------------------------------------------------------------*/
51 inline void to_lower(std::string* s)
53 assert(s);
54 for (std::string::iterator i = s->begin(); i != s->end(); ++i) {
55 *i = static_cast<char>(tolower(*i));
58 /*--------------------------------------------------------------------------*/
59 inline std::string to_lower(const std::string s)
61 std::string c(s);
62 to_lower(&c);
63 return c;
65 /*--------------------------------------------------------------------------*/
66 inline void to_upper(std::string* s)
68 assert(s);
69 for (std::string::iterator i = s->begin(); i != s->end(); ++i) {
70 *i = static_cast<char>(toupper(*i));
73 /*--------------------------------------------------------------------------*/
75 /*--------------------------------------------------------------------------*/
76 /*--------------------------------------------------------------------------*/
77 #endif
78 // vim:ts=8:sw=2:noet: