stl_numeric.h (iota): Add in C++0x mode.
2008-06-27 Paolo Carlini <paolo.carlini@oracle.com> * include/bits/stl_numeric.h (iota): Add in C++0x mode. * testsuite/util/testsuite_character.h (pod_int): Add operator++ in C++0x mode. * testsuite/util/testsuite_api.h (NonDefaultConstructible): Likewise. * testsuite/26_numerics/iota/1.cc: New. * testsuite/26_numerics/iota/requirements/explicit_instantiation/ 2.cc: Likewise. * testsuite/26_numerics/iota/requirements/explicit_instantiation/ pod.cc: Likewise. * include/ext/algorithm: Do not fiddle with the legacy headers. * testsuite/26_numerics/partial_sum/1.cc: Minor changes, comments, style. * testsuite/26_numerics/accumulate/1.cc: Likewise. * testsuite/26_numerics/adjacent_difference/1.cc: Likewise. * testsuite/26_numerics/inner_product/1.cc: Likewise. From-SVN: r137174
This commit is contained in:
parent
d9338c6726
commit
fa52081d86
|
@ -1,3 +1,23 @@
|
||||||
|
2008-06-27 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
* include/bits/stl_numeric.h (iota): Add in C++0x mode.
|
||||||
|
* testsuite/util/testsuite_character.h (pod_int): Add operator++
|
||||||
|
in C++0x mode.
|
||||||
|
* testsuite/util/testsuite_api.h (NonDefaultConstructible): Likewise.
|
||||||
|
* testsuite/26_numerics/iota/1.cc: New.
|
||||||
|
* testsuite/26_numerics/iota/requirements/explicit_instantiation/
|
||||||
|
2.cc: Likewise.
|
||||||
|
* testsuite/26_numerics/iota/requirements/explicit_instantiation/
|
||||||
|
pod.cc: Likewise.
|
||||||
|
|
||||||
|
* include/ext/algorithm: Do not fiddle with the legacy headers.
|
||||||
|
|
||||||
|
* testsuite/26_numerics/partial_sum/1.cc: Minor changes, comments,
|
||||||
|
style.
|
||||||
|
* testsuite/26_numerics/accumulate/1.cc: Likewise.
|
||||||
|
* testsuite/26_numerics/adjacent_difference/1.cc: Likewise.
|
||||||
|
* testsuite/26_numerics/inner_product/1.cc: Likewise.
|
||||||
|
|
||||||
2008-06-26 Paolo Carlini <paolo.carlini@oracle.com>
|
2008-06-26 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
* include/bits/stl_algo.h (partition_copy): Add in C++0x mode.
|
* include/bits/stl_algo.h (partition_copy): Add in C++0x mode.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Numeric functions implementation -*- C++ -*-
|
// Numeric functions implementation -*- C++ -*-
|
||||||
|
|
||||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||||
// Free Software Foundation, Inc.
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
@ -65,6 +65,43 @@
|
||||||
#include <bits/concept_check.h>
|
#include <bits/concept_check.h>
|
||||||
#include <debug/debug.h>
|
#include <debug/debug.h>
|
||||||
|
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create a range of sequentially increasing values.
|
||||||
|
*
|
||||||
|
* For each element in the range @p [first,last) assigns @p value and
|
||||||
|
* increments @p value as if by @p ++value.
|
||||||
|
*
|
||||||
|
* @param first Start of range.
|
||||||
|
* @param last End of range.
|
||||||
|
* @param value Starting value.
|
||||||
|
* @return Nothing.
|
||||||
|
*/
|
||||||
|
template<typename _ForwardIterator, typename _Tp>
|
||||||
|
void
|
||||||
|
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
|
||||||
|
{
|
||||||
|
// concept requirements
|
||||||
|
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
|
||||||
|
_ForwardIterator>)
|
||||||
|
__glibcxx_function_requires(_ConvertibleConcept<_Tp,
|
||||||
|
typename iterator_traits<_ForwardIterator>::value_type>)
|
||||||
|
__glibcxx_requires_valid_range(__first, __last);
|
||||||
|
|
||||||
|
for (; __first != __last; ++__first)
|
||||||
|
{
|
||||||
|
*__first = __value;
|
||||||
|
++__value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
|
_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,7 +201,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
|
||||||
* @return The final inner product.
|
* @return The final inner product.
|
||||||
*/
|
*/
|
||||||
template<typename _InputIterator1, typename _InputIterator2, typename _Tp,
|
template<typename _InputIterator1, typename _InputIterator2, typename _Tp,
|
||||||
typename _BinaryOperation1, typename _BinaryOperation2>
|
typename _BinaryOperation1, typename _BinaryOperation2>
|
||||||
inline _Tp
|
inline _Tp
|
||||||
inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||||
_InputIterator2 __first2, _Tp __init,
|
_InputIterator2 __first2, _Tp __init,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Algorithm extensions -*- C++ -*-
|
// Algorithm extensions -*- C++ -*-
|
||||||
|
|
||||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||||
// Free Software Foundation, Inc.
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
@ -428,10 +428,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||||
__out_last - __out_first);
|
__out_last - __out_first);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
||||||
using std::is_heap;
|
|
||||||
using std::is_sorted;
|
|
||||||
#else
|
|
||||||
/**
|
/**
|
||||||
* This is an SGI extension.
|
* This is an SGI extension.
|
||||||
* @ingroup SGIextensions
|
* @ingroup SGIextensions
|
||||||
|
@ -527,7 +523,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE
|
_GLIBCXX_END_NAMESPACE
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
|
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||||
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// 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
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
@ -48,7 +49,7 @@ test02()
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
test02();
|
test02();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
|
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||||
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// 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
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
@ -16,7 +17,6 @@
|
||||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
// USA.
|
// USA.
|
||||||
|
|
||||||
// 26.4.3 [lib.partial.sum]
|
|
||||||
// 26.4.4 [lib.adjacent.difference]
|
// 26.4.4 [lib.adjacent.difference]
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -41,6 +41,6 @@ test01()
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
|
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||||
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// 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
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
@ -50,7 +51,7 @@ test02()
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
test02();
|
test02();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
// 2008-06-27 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
// Copyright (C) 2008 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 of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
int A[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
int B[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||||
|
int C[] = {-9, -8, -7, -6, -5, -4, -3, -2, -1};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
|
std::iota(A, A + N, 1);
|
||||||
|
VERIFY( std::equal(A, A + N, B) );
|
||||||
|
|
||||||
|
std::iota(A, A + N, -9);
|
||||||
|
VERIFY( std::equal(A, A + N, C) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
// 2008-06-27 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
// Copyright (C) 2008 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 of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// As a special exception, you may use this file as part of a free software
|
||||||
|
// library without restriction. Specifically, if other files instantiate
|
||||||
|
// templates or use macros or inline functions from this file, or you compile
|
||||||
|
// this file and link it with other files to produce an executable, this
|
||||||
|
// file does not by itself cause the resulting executable to be covered by
|
||||||
|
// the GNU General Public License. This exception does not however
|
||||||
|
// invalidate any other reasons why the executable file might be covered by
|
||||||
|
// the GNU General Public License.
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
#include <testsuite_api.h>
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
typedef __gnu_test::NonDefaultConstructible value_type;
|
||||||
|
typedef value_type* iterator_type;
|
||||||
|
|
||||||
|
template void iota(iterator_type, iterator_type, value_type);
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
// 2008-06-27 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
// Copyright (C) 2008 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 of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// As a special exception, you may use this file as part of a free software
|
||||||
|
// library without restriction. Specifically, if other files instantiate
|
||||||
|
// templates or use macros or inline functions from this file, or you compile
|
||||||
|
// this file and link it with other files to produce an executable, this
|
||||||
|
// file does not by itself cause the resulting executable to be covered by
|
||||||
|
// the GNU General Public License. This exception does not however
|
||||||
|
// invalidate any other reasons why the executable file might be covered by
|
||||||
|
// the GNU General Public License.
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
#include <testsuite_character.h>
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
typedef __gnu_test::pod_int value_type;
|
||||||
|
typedef value_type* iterator_type;
|
||||||
|
|
||||||
|
template void iota(iterator_type, iterator_type, value_type);
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
|
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||||
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// 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
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
@ -17,7 +18,6 @@
|
||||||
// USA.
|
// USA.
|
||||||
|
|
||||||
// 26.4.3 [lib.partial.sum]
|
// 26.4.3 [lib.partial.sum]
|
||||||
// 26.4.4 [lib.adjacent.difference]
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
|
@ -84,6 +84,13 @@ namespace __gnu_test
|
||||||
{
|
{
|
||||||
NonDefaultConstructible(int) { }
|
NonDefaultConstructible(int) { }
|
||||||
NonDefaultConstructible(const NonDefaultConstructible&) { }
|
NonDefaultConstructible(const NonDefaultConstructible&) { }
|
||||||
|
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
// For std::iota.
|
||||||
|
NonDefaultConstructible&
|
||||||
|
operator++()
|
||||||
|
{ return *this; }
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// See: 20.1.1 Template argument requirements.
|
// See: 20.1.1 Template argument requirements.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
// Testing character type and state type with char_traits and codecvt
|
// Testing character type and state type with char_traits and codecvt
|
||||||
// specializations for the C++ library testsuite.
|
// specializations for the C++ library testsuite.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
|
||||||
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// 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
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
@ -44,6 +45,16 @@ namespace __gnu_test
|
||||||
struct pod_int
|
struct pod_int
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
// For std::iota.
|
||||||
|
pod_int&
|
||||||
|
operator++()
|
||||||
|
{
|
||||||
|
++value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// For 20.1 requirements for instantiable type: equality comparable
|
// For 20.1 requirements for instantiable type: equality comparable
|
||||||
|
|
Loading…
Reference in New Issue