Commit 15d72060 by Paolo Carlini Committed by Paolo Carlini

stl_construct.h: Wrap overlong lines, reformat according to the coding standards.

2004-02-06  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/stl_construct.h: Wrap overlong lines, reformat
	according to the coding standards.
	* include/bits/stl_pair.h: Likewise.
	* include/bits/stl_raw_storage_iter.h: Likewise.
	* include/bits/stl_stack.h: Likewise.
	* include/bits/stl_uninitialized.h: Likewise.
	* include/bits/stream_iterator.h: Likewise.
	* include/bits/streambuf_iterator.h: Likewise.
	* include/bits/type_traits.h: Likewise.

From-SVN: r77425
parent 0a2d3d69
2004-02-06 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_construct.h: Wrap overlong lines, reformat
according to the coding standards.
* include/bits/stl_pair.h: Likewise.
* include/bits/stl_raw_storage_iter.h: Likewise.
* include/bits/stl_stack.h: Likewise.
* include/bits/stl_uninitialized.h: Likewise.
* include/bits/stream_iterator.h: Likewise.
* include/bits/streambuf_iterator.h: Likewise.
* include/bits/type_traits.h: Likewise.
2004-02-06 Paolo Carlini <pcarlini@suse.de>
* testsuite/27_io/basic_filebuf/open/char/9507.cc:
Adjust timings.
......
// nonstandard construct and destroy functions -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004 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
......@@ -115,7 +115,8 @@ namespace std
*/
template<typename _ForwardIterator>
inline void
__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
__destroy_aux(_ForwardIterator __first, _ForwardIterator __last,
__false_type)
{ for ( ; __first != __last; ++__first) std::_Destroy(&*__first); }
/**
......
// Pair implementation -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc.
// Copyright (C) 2001, 2004 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
......@@ -64,85 +64,88 @@
namespace std
{
/// pair holds two objects of arbitrary type.
template <class _T1, class _T2>
struct pair {
typedef _T1 first_type; ///< @c first_type is the first bound type
typedef _T2 second_type; ///< @c second_type is the second bound type
/// pair holds two objects of arbitrary type.
template <class _T1, class _T2>
struct pair
{
typedef _T1 first_type; ///< @c first_type is the first bound type
typedef _T2 second_type; ///< @c second_type is the second bound type
_T1 first; ///< @c first is a copy of the first object
_T2 second; ///< @c second is a copy of the second object
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 265. std::pair::pair() effects overly restrictive
/** The default constructor creates @c first and @c second using their
* respective default constructors. */
pair()
: first(), second() {}
/** Two objects may be passed to a @c pair constructor to be copied. */
pair(const _T1& __a, const _T2& __b)
: first(__a), second(__b) {}
/** There is also a templated copy ctor for the @c pair class itself. */
template <class _U1, class _U2>
pair(const pair<_U1, _U2>& __p)
: first(__p.first), second(__p.second) {}
};
/// Two pairs of the same type are equal iff their members are equal.
template <class _T1, class _T2>
inline bool
operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return __x.first == __y.first && __x.second == __y.second; }
/// <http://gcc.gnu.org/onlinedocs/libstdc++/20_util/howto.html#pairlt>
template <class _T1, class _T2>
inline bool
operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return __x.first < __y.first
|| (!(__y.first < __x.first) && __x.second < __y.second); }
/// Uses @c operator== to find the result.
template <class _T1, class _T2>
inline bool
operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return !(__x == __y); }
/// Uses @c operator< to find the result.
template <class _T1, class _T2>
inline bool
operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return __y < __x; }
/// Uses @c operator< to find the result.
template <class _T1, class _T2>
inline bool
operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return !(__y < __x); }
/// Uses @c operator< to find the result.
template <class _T1, class _T2>
inline bool
operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{ return !(__x < __y); }
/**
* @brief A convenience wrapper for creating a pair from two objects.
* @param x The first object.
* @param y The second object.
* @return A newly-constructed pair<> object of the appropriate type.
*
* The standard requires that the objects be passed by reference-to-const,
* but LWG issue #181 says they should be passed by const value. We follow
* the LWG by default.
*/
template <class _T1, class _T2>
_T1 first; ///< @c first is a copy of the first object
_T2 second; ///< @c second is a copy of the second object
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 265. std::pair::pair() effects overly restrictive
/** The default constructor creates @c first and @c second using their
* respective default constructors. */
pair() : first(), second() {}
/** Two objects may be passed to a @c pair constructor to be copied. */
pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
/** There is also a templated copy ctor for the @c pair class itself. */
template <class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
};
/// Two pairs of the same type are equal iff their members are equal.
template <class _T1, class _T2>
inline bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{
return __x.first == __y.first && __x.second == __y.second;
}
/// <http://gcc.gnu.org/onlinedocs/libstdc++/20_util/howto.html#pairlt>
template <class _T1, class _T2>
inline bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{
return __x.first < __y.first ||
(!(__y.first < __x.first) && __x.second < __y.second);
}
/// Uses @c operator== to find the result.
template <class _T1, class _T2>
inline bool operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
return !(__x == __y);
}
/// Uses @c operator< to find the result.
template <class _T1, class _T2>
inline bool operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
return __y < __x;
}
/// Uses @c operator< to find the result.
template <class _T1, class _T2>
inline bool operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
return !(__y < __x);
}
/// Uses @c operator< to find the result.
template <class _T1, class _T2>
inline bool operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
return !(__x < __y);
}
/**
* @brief A convenience wrapper for creating a pair from two objects.
* @param x The first object.
* @param y The second object.
* @return A newly-constructed pair<> object of the appropriate type.
*
* The standard requires that the objects be passed by reference-to-const,
* but LWG issue #181 says they should be passed by const value. We follow
* the LWG by default.
*/
template <class _T1, class _T2>
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 181. make_pair() unintended behavior
inline pair<_T1, _T2> make_pair(_T1 __x, _T2 __y)
{
return pair<_T1, _T2>(__x, __y);
}
// 181. make_pair() unintended behavior
inline pair<_T1, _T2>
make_pair(_T1 __x, _T2 __y)
{ return pair<_T1, _T2>(__x, __y); }
} // namespace std
#endif /* _PAIR_H */
......
// -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc.
// Copyright (C) 2001, 2004 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
......@@ -68,7 +68,7 @@ namespace std
* uninitialized memory.
*/
template <class _ForwardIterator, class _Tp>
class raw_storage_iterator
class raw_storage_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{
protected:
......@@ -76,7 +76,8 @@ namespace std
public:
explicit
raw_storage_iterator(_ForwardIterator __x) : _M_iter(__x) {}
raw_storage_iterator(_ForwardIterator __x)
: _M_iter(__x) {}
raw_storage_iterator&
operator*() { return *this; }
......
// Stack implementation -*- C++ -*-
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2004 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
......@@ -79,7 +79,6 @@ namespace std
inline bool
operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
/**
* @brief A standard container giving FILO behavior.
*
......@@ -116,9 +115,9 @@ namespace std
__glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
__glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
template<typename _Tp1, typename _Seq1>
friend bool
operator==(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
template<typename _Tp1, typename _Seq1>
friend bool
operator==(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
template<typename _Tp1, typename _Seq1>
friend bool
......@@ -141,17 +140,20 @@ namespace std
* @brief Default constructor creates no elements.
*/
explicit
stack(const _Sequence& __c = _Sequence()) : c(__c) {}
stack(const _Sequence& __c = _Sequence())
: c(__c) {}
/**
* Returns true if the %stack is empty.
*/
bool
empty() const { return c.empty(); }
empty() const
{ return c.empty(); }
/** Returns the number of elements in the %stack. */
size_type
size() const { return c.size(); }
size() const
{ return c.size(); }
/**
* Returns a read/write reference to the data at the first
......@@ -185,7 +187,8 @@ namespace std
* underlying sequence.
*/
void
push(const value_type& __x) { c.push_back(__x); }
push(const value_type& __x)
{ c.push_back(__x); }
/**
* @brief Removes first element.
......@@ -206,7 +209,6 @@ namespace std
}
};
/**
* @brief Stack equality comparison.
* @param x A %stack.
......@@ -221,7 +223,7 @@ namespace std
*/
template<typename _Tp, typename _Seq>
inline bool
operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
operator==(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return __x.c == __y.c; }
/**
......@@ -239,31 +241,31 @@ namespace std
*/
template<typename _Tp, typename _Seq>
inline bool
operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
operator<(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return __x.c < __y.c; }
/// Based on operator==
template<typename _Tp, typename _Seq>
inline bool
operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
operator!=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Seq>
inline bool
operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
operator>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Seq>
inline bool
operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
operator<=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Seq>
inline bool
operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
operator>=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return !(__x < __y); }
} // namespace std
......
// Raw memory manipulators -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc.
// Copyright (C) 2001, 2004 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
......@@ -109,7 +109,8 @@ namespace std
{
typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD;
return std::__uninitialized_copy_aux(__first, __last, __result, _Is_POD());
return std::__uninitialized_copy_aux(__first, __last, __result,
_Is_POD());
}
inline char*
......@@ -138,15 +139,15 @@ namespace std
template<typename _ForwardIterator, typename _Tp>
void
__uninitialized_fill_aux(_ForwardIterator __first,
_ForwardIterator __last,
__uninitialized_fill_aux(_ForwardIterator __first, _ForwardIterator __last,
const _Tp& __x, __false_type)
{
_ForwardIterator __cur = __first;
try {
for ( ; __cur != __last; ++__cur)
std::_Construct(&*__cur, __x);
}
try
{
for ( ; __cur != __last; ++__cur)
std::_Construct(&*__cur, __x);
}
catch(...)
{
std::_Destroy(__first, __cur);
......@@ -235,10 +236,12 @@ namespace std
_InputIterator2 __last2,
_ForwardIterator __result)
{
_ForwardIterator __mid = std::uninitialized_copy(__first1, __last1, __result);
try {
return std::uninitialized_copy(__first2, __last2, __mid);
}
_ForwardIterator __mid = std::uninitialized_copy(__first1, __last1,
__result);
try
{
return std::uninitialized_copy(__first2, __last2, __mid);
}
catch(...)
{
std::_Destroy(__result, __mid);
......@@ -252,13 +255,14 @@ namespace std
template<typename _ForwardIterator, typename _Tp, typename _InputIterator>
inline _ForwardIterator
__uninitialized_fill_copy(_ForwardIterator __result, _ForwardIterator __mid,
const _Tp& __x,
_InputIterator __first, _InputIterator __last)
const _Tp& __x, _InputIterator __first,
_InputIterator __last)
{
std::uninitialized_fill(__result, __mid, __x);
try {
return std::uninitialized_copy(__first, __last, __mid);
}
try
{
return std::uninitialized_copy(__first, __last, __mid);
}
catch(...)
{
std::_Destroy(__result, __mid);
......@@ -272,8 +276,8 @@ namespace std
template<typename _InputIterator, typename _ForwardIterator, typename _Tp>
inline void
__uninitialized_copy_fill(_InputIterator __first1, _InputIterator __last1,
_ForwardIterator __first2, _ForwardIterator __last2,
const _Tp& __x)
_ForwardIterator __first2,
_ForwardIterator __last2, const _Tp& __x)
{
_ForwardIterator __mid2 = std::uninitialized_copy(__first1, __last1,
__first2);
......
......@@ -45,7 +45,7 @@ namespace std
template<typename _Tp, typename _CharT = char,
typename _Traits = char_traits<_CharT>, typename _Dist = ptrdiff_t>
class istream_iterator
: public iterator<input_iterator_tag, _Tp, _Dist, const _Tp*, const _Tp&>
: public iterator<input_iterator_tag, _Tp, _Dist, const _Tp*, const _Tp&>
{
public:
typedef _CharT char_type;
......@@ -59,10 +59,13 @@ namespace std
public:
/// Construct end of input stream iterator.
istream_iterator() : _M_stream(0), _M_ok(false) {}
istream_iterator()
: _M_stream(0), _M_ok(false) {}
/// Construct start of input stream iterator.
istream_iterator(istream_type& __s) : _M_stream(&__s) { _M_read(); }
istream_iterator(istream_type& __s)
: _M_stream(&__s)
{ _M_read(); }
istream_iterator(const istream_iterator& __obj)
: _M_stream(__obj._M_stream), _M_value(__obj._M_value),
......@@ -104,14 +107,14 @@ namespace std
bool
_M_equal(const istream_iterator& __x) const
{ return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream);}
{ return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); }
private:
void
_M_read()
{
_M_ok = (_M_stream && *_M_stream) ? true : false;
if (_M_ok)
if (_M_ok)
{
*_M_stream >> _M_value;
_M_ok = *_M_stream ? true : false;
......@@ -133,7 +136,6 @@ namespace std
const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y)
{ return !__x._M_equal(__y); }
/**
* @brief Provides output iterator semantics for streams.
*
......@@ -148,7 +150,7 @@ namespace std
template<typename _Tp, typename _CharT = char,
typename _Traits = char_traits<_CharT> >
class ostream_iterator
: public iterator<output_iterator_tag, void, void, void, void>
: public iterator<output_iterator_tag, void, void, void, void>
{
public:
//@{
......@@ -197,13 +199,16 @@ namespace std
}
ostream_iterator&
operator*() { return *this; }
operator*()
{ return *this; }
ostream_iterator&
operator++() { return *this; }
operator++()
{ return *this; }
ostream_iterator&
operator++(int) { return *this; }
operator++(int)
{ return *this; }
};
} // namespace std
#endif
......@@ -159,9 +159,9 @@ namespace std
{
if (!traits_type::eq_int_type(_M_c, __eof))
__ret = _M_c;
else
if (traits_type::eq_int_type((__ret = _M_sbuf->sgetc()), __eof))
_M_sbuf = 0;
else if (traits_type::eq_int_type((__ret = _M_sbuf->sgetc()),
__eof))
_M_sbuf = 0;
}
return __ret;
}
......@@ -248,7 +248,8 @@ namespace std
_M_put(const _CharT* __ws, streamsize __len)
{
if (__builtin_expect(!_M_failed, true)
&& __builtin_expect(this->_M_sbuf->sputn(__ws, __len) != __len, false))
&& __builtin_expect(this->_M_sbuf->sputn(__ws, __len) != __len,
false))
_M_failed = true;
return *this;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment