This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Do not include <climits>
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Sat, 17 Feb 2007 15:43:59 +0100
- Subject: [Patch] Do not include <climits>
Hi,
while working on something else, I noticed that by tweaking the
codecvt_members.cc includes and consistently using __CHAR_BIT__ in
stl_bvector.h too we can avoid including <climits> anywhere in the headers.
Tested x86/x86-64-linux, also --enable-clocale=generic and without PCHs.
Paolo.
///////////////////////
2007-02-17 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_algobase.h: Do not include <climits>, use
std::numeric_limits.
* include/bits/stl_bvector.h: Use __CHAR_BIT__.
* config/locale/gnu/codecvt_members.cc: Include <climits>.
* config/locale/generic/codecvt_members.cc: Likewise.
Index: include/bits/stl_algobase.h
===================================================================
--- include/bits/stl_algobase.h (revision 122039)
+++ include/bits/stl_algobase.h (working copy)
@@ -65,7 +65,6 @@
#include <bits/c++config.h>
#include <cstring>
#include <cwchar>
-#include <climits>
#include <cstdlib>
#include <cstddef>
#include <iosfwd>
@@ -318,8 +317,8 @@
// Helpers for streambuf iterators (either istream or ostream).
template<typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
- ostreambuf_iterator<_CharT> >::__type
+ typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
+ ostreambuf_iterator<_CharT> >::__type
__copy_aux(_CharT*, _CharT*, ostreambuf_iterator<_CharT>);
template<typename _CharT>
@@ -328,7 +327,8 @@
__copy_aux(const _CharT*, const _CharT*, ostreambuf_iterator<_CharT>);
template<typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, _CharT*>::__type
+ typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
+ _CharT*>::__type
__copy_aux(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>,
_CharT*);
@@ -979,17 +979,16 @@
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
-#if CHAR_MAX == SCHAR_MAX
- return std::lexicographical_compare((const signed char*) __first1,
- (const signed char*) __last1,
- (const signed char*) __first2,
- (const signed char*) __last2);
-#else /* CHAR_MAX == SCHAR_MAX */
- return std::lexicographical_compare((const unsigned char*) __first1,
- (const unsigned char*) __last1,
- (const unsigned char*) __first2,
- (const unsigned char*) __last2);
-#endif /* CHAR_MAX == SCHAR_MAX */
+ if (std::numeric_limits<char>::is_signed)
+ return std::lexicographical_compare((const signed char*) __first1,
+ (const signed char*) __last1,
+ (const signed char*) __first2,
+ (const signed char*) __last2);
+ else
+ return std::lexicographical_compare((const unsigned char*) __first1,
+ (const unsigned char*) __last1,
+ (const unsigned char*) __first2,
+ (const unsigned char*) __last2);
}
_GLIBCXX_END_NAMESPACE
Index: include/bits/stl_bvector.h
===================================================================
--- include/bits/stl_bvector.h (revision 122039)
+++ include/bits/stl_bvector.h (working copy)
@@ -1,6 +1,6 @@
// vector<bool> specialization -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -65,7 +65,7 @@
_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
typedef unsigned long _Bit_type;
- enum { _S_word_bit = int(CHAR_BIT * sizeof(_Bit_type)) };
+ enum { _S_word_bit = int(__CHAR_BIT__ * sizeof(_Bit_type)) };
struct _Bit_reference
{
Index: config/locale/gnu/codecvt_members.cc
===================================================================
--- config/locale/gnu/codecvt_members.cc (revision 122039)
+++ config/locale/gnu/codecvt_members.cc (working copy)
@@ -1,6 +1,7 @@
// std::codecvt implementation details, GNU version -*- C++ -*-
-// Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+// 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
@@ -34,6 +35,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
+#include <climits> // For MB_LEN_MAX and MB_CUR_MAX
#include <bits/c++locale_internal.h>
_GLIBCXX_BEGIN_NAMESPACE(std)
Index: config/locale/generic/codecvt_members.cc
===================================================================
--- config/locale/generic/codecvt_members.cc (revision 122039)
+++ config/locale/generic/codecvt_members.cc (working copy)
@@ -1,6 +1,7 @@
// std::codecvt implementation details, generic version -*- C++ -*-
-// Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+// 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
@@ -34,6 +35,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
+#include <climits> // For MB_LEN_MAX and MB_CUR_MAX
_GLIBCXX_BEGIN_NAMESPACE(std)