type_traits.h: Fix __glibcxx_max macro.

2007-01-15  Ian Lance Taylor  <iant@google.com>
	    Paolo Carlini  <pcarlini@suse.de>

	* include/ext/type_traits.h: Fix __glibcxx_max macro.
	* include/std/limits: Likewise.

Co-Authored-By: Paolo Carlini <pcarlini@suse.de>

From-SVN: r120808
This commit is contained in:
Ian Lance Taylor 2007-01-16 00:01:24 +00:00 committed by Paolo Carlini
parent af7a7593fa
commit 6ae39fd99e
3 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2007-01-15 Ian Lance Taylor <iant@google.com>
Paolo Carlini <pcarlini@suse.de>
* include/ext/type_traits.h: Fix __glibcxx_max macro.
* include/std/limits: Likewise.
2007-01-15 Paolo Carlini <pcarlini@suse.de>
* include/std/valarray (valarray<>::cshift): Fix typo.

View File

@ -1,6 +1,6 @@
// -*- C++ -*-
// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
// Copyright (C) 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 terms
@ -161,7 +161,8 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
(__glibcxx_signed(_Tp) ? (_Tp)1 << __glibcxx_digits(_Tp) : (_Tp)0)
#define __glibcxx_max(_Tp) \
(__glibcxx_signed(_Tp) ? ((_Tp)1 << __glibcxx_digits(_Tp)) - 1 : ~(_Tp)0)
(__glibcxx_signed(_Tp) ? \
(((((_Tp)1 << (__glibcxx_digits(_Tp) - 1)) - 1) << 1) + 1) : ~(_Tp)0)
template<typename _Value>
struct __numeric_traits_integer
@ -197,4 +198,9 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
_GLIBCXX_END_NAMESPACE
#undef __glibcxx_signed
#undef __glibcxx_min
#undef __glibcxx_max
#undef __glibcxx_digits
#endif

View File

@ -1,6 +1,6 @@
// The template and inlines for the numeric_limits classes. -*- C++ -*-
// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005
// Copyright (C) 1999, 2000, 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
@ -137,7 +137,8 @@
(__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0)
#define __glibcxx_max(T) \
(__glibcxx_signed (T) ? ((T)1 << __glibcxx_digits (T)) - 1 : ~(T)0)
(__glibcxx_signed (T) ? \
(((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0)
#define __glibcxx_digits(T) \
(sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))