Commit 01b0d4b8 by Paolo Carlini Committed by Paolo Carlini

stl_numeric.h (power + helpers, iota): Move to...

2002-01-02  Paolo Carlini  <pcarlini@unitus.it>

	* include/bits/stl_numeric.h (power + helpers, iota):  Move to...
	* include/ext/numeric:  ...here, new file.
        * include/bits/stl_function.h (identity_element, unary_compose,
	binary_compose, compose1, compose2, identity, select1st,
	select2nd, project1st + helper, project2nd + helper,
	constant_void_fun + helper, constant_unary_fun + helper,
	costant_binary_fun + helper, constant0, constant1, constant2,
	subtractive_rng, mem_fun1, mem_fun1_ref):  Move to...
        * include/ext/functional:  ...here, new file.
        * include/Makefile.am (ext_headers):  Add new files.
        * include/Makefile.in:  Regenerate.
        * testsuite/ext/headers.cc:  Include <ext/numeric> and
	<ext/functional>.
	* include/backward/algo.h:  Include <ext/numeric>, tweak.
	* include/backward/function.h:  Include <ext/functional>, tweak.
        * include/ext/ropeimpl.h:  Include <ext/numeric>.

From-SVN: r48519
parent d15a58c0
2002-01-03 Paolo Carlini <pcarlini@unitus.it>
* include/bits/stl_numeric.h (power + helpers, iota): Move to...
* include/ext/numeric: ...here, new file.
* include/bits/stl_function.h (identity_element, unary_compose,
binary_compose, compose1, compose2, identity, select1st,
select2nd, project1st + helper, project2nd + helper,
constant_void_fun + helper, constant_unary_fun + helper,
costant_binary_fun + helper, constant0, constant1, constant2,
subtractive_rng, mem_fun1, mem_fun1_ref): Move to...
* include/ext/functional: ...here, new file.
* include/Makefile.am (ext_headers): Add new files.
* include/Makefile.in: Regenerate.
* testsuite/ext/headers.cc: Include <ext/numeric> and
<ext/functional>.
* include/backward/algo.h: Include <ext/numeric>, tweak.
* include/backward/function.h: Include <ext/functional>, tweak.
* include/ext/ropeimpl.h: Include <ext/numeric>.
Thu Jan 3 11:05:41 2002 Jeffrey A Law (law@redhat.com)
* config/os/hpux/bits/os_defines.h: Prefix __strtoll and
......
......@@ -173,10 +173,12 @@ ext_srcdir = ${glibcpp_srcdir}/include/ext
ext_builddir = ./ext
ext_headers = \
${ext_srcdir}/algorithm \
${ext_srcdir}/functional \
${ext_srcdir}/hash_map \
${ext_srcdir}/hash_set \
${ext_srcdir}/iterator \
${ext_srcdir}/memory \
${ext_srcdir}/numeric \
${ext_srcdir}/rope \
${ext_srcdir}/ropeimpl.h \
${ext_srcdir}/slist \
......
......@@ -303,10 +303,12 @@ ext_srcdir = ${glibcpp_srcdir}/include/ext
ext_builddir = ./ext
ext_headers = \
${ext_srcdir}/algorithm \
${ext_srcdir}/functional \
${ext_srcdir}/hash_map \
${ext_srcdir}/hash_set \
${ext_srcdir}/iterator \
${ext_srcdir}/memory \
${ext_srcdir}/numeric \
${ext_srcdir}/rope \
${ext_srcdir}/ropeimpl.h \
${ext_srcdir}/slist \
......
......@@ -63,6 +63,7 @@
#include <bits/stl_algo.h>
#include <bits/stl_numeric.h>
#include <ext/algorithm>
#include <ext/numeric>
// Names from <stl_algo.h>
using std::for_each;
......@@ -128,8 +129,6 @@ using std::accumulate;
using std::inner_product;
using std::partial_sum;
using std::adjacent_difference;
using std::power;
using std::iota;
// Names from ext/algorithm
using __gnu_cxx::random_sample;
......@@ -139,6 +138,10 @@ using __gnu_cxx::is_heap;
using __gnu_cxx::count; // Extension returning void
using __gnu_cxx::count_if; // Extension returning void
// Names from ext/numeric
using __gnu_cxx::power;
using __gnu_cxx::iota;
#endif /* _CPP_BACKWARD_ALGO_H */
// Local Variables:
......
......@@ -60,6 +60,7 @@
#include <bits/c++config.h>
#include <stddef.h>
#include <bits/stl_function.h>
#include <ext/functional>
// Names from stl_function.h
using std::unary_function;
......@@ -68,7 +69,6 @@ using std::plus;
using std::minus;
using std::multiplies;
using std::divides;
using std::identity_element;
using std::modulus;
using std::negate;
using std::equal_to;
......@@ -88,25 +88,9 @@ using std::binder1st;
using std::binder2nd;
using std::bind1st;
using std::bind2nd;
using std::unary_compose;
using std::binary_compose;
using std::compose1;
using std::compose2;
using std::pointer_to_unary_function;
using std::pointer_to_binary_function;
using std::ptr_fun;
using std::identity;
using std::select1st;
using std::select2nd;
using std::project1st;
using std::project2nd;
using std::constant_void_fun;
using std::constant_unary_fun;
using std::constant_binary_fun;
using std::constant0;
using std::constant1;
using std::constant2;
using std::subtractive_rng;
using std::mem_fun_t;
using std::const_mem_fun_t;
using std::mem_fun_ref_t;
......@@ -117,8 +101,27 @@ using std::mem_fun1_ref_t;
using std::const_mem_fun1_ref_t;
using std::mem_fun;
using std::mem_fun_ref;
using std::mem_fun1;
using std::mem_fun1_ref;
// Names from ext/functional
using __gnu_cxx::identity_element;
using __gnu_cxx::unary_compose;
using __gnu_cxx::binary_compose;
using __gnu_cxx::compose1;
using __gnu_cxx::compose2;
using __gnu_cxx::identity;
using __gnu_cxx::select1st;
using __gnu_cxx::select2nd;
using __gnu_cxx::project1st;
using __gnu_cxx::project2nd;
using __gnu_cxx::constant_void_fun;
using __gnu_cxx::constant_unary_fun;
using __gnu_cxx::constant_binary_fun;
using __gnu_cxx::constant0;
using __gnu_cxx::constant1;
using __gnu_cxx::constant2;
using __gnu_cxx::subtractive_rng;
using __gnu_cxx::mem_fun1;
using __gnu_cxx::mem_fun1_ref;
#endif /* _CPP_BACKWARD_FUNCTION_H */
......
......@@ -206,67 +206,6 @@ namespace std
return ++__result;
}
// Returns __x ** __n, where __n >= 0. _Note that "multiplication"
// is required to be associative, but not necessarily commutative.
template<typename _Tp, typename _Integer, typename _MonoidOperation>
_Tp
__power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
{
if (__n == 0)
return identity_element(__monoid_op);
else {
while ((__n & 1) == 0) {
__n >>= 1;
__x = __monoid_op(__x, __x);
}
_Tp __result = __x;
__n >>= 1;
while (__n != 0) {
__x = __monoid_op(__x, __x);
if ((__n & 1) != 0)
__result = __monoid_op(__result, __x);
__n >>= 1;
}
return __result;
}
}
template<typename _Tp, typename _Integer>
inline _Tp
__power(_Tp __x, _Integer __n)
{ return __power(__x, __n, multiplies<_Tp>()); }
// Alias for the internal name __power. Note that power is an extension,
// not part of the C++ standard.
template<typename _Tp, typename _Integer, typename _MonoidOperation>
inline _Tp
power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
{ return __power(__x, __n, __monoid_op); }
template<typename _Tp, typename _Integer>
inline _Tp
power(_Tp __x, _Integer __n)
{ return __power(__x, __n); }
// iota is not part of the C++ standard. It is an extension.
template<typename _ForwardIter, typename _Tp>
void
iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
{
// concept requirements
__glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter>)
__glibcpp_function_requires(_ConvertibleConcept<_Tp,
typename iterator_traits<_ForwardIter>::value_type>)
while (__first != __last)
*__first++ = __value++;
}
} // namespace std
#endif /* _CPP_BITS_STL_NUMERIC_H */
......
// Numeric extensions -*- C++ -*-
// Copyright (C) 2002 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// 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.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
#ifndef _EXT_NUMERIC
#define _EXT_NUMERIC
#pragma GCC system_header
#include <bits/concept_check.h>
#include <bits/std_numeric.h>
#include <ext/functional> // For identity_element
namespace __gnu_cxx
{
// Returns __x ** __n, where __n >= 0. _Note that "multiplication"
// is required to be associative, but not necessarily commutative.
template<typename _Tp, typename _Integer, typename _MonoidOperation>
_Tp
__power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
{
if (__n == 0)
return identity_element(__monoid_op);
else {
while ((__n & 1) == 0) {
__n >>= 1;
__x = __monoid_op(__x, __x);
}
_Tp __result = __x;
__n >>= 1;
while (__n != 0) {
__x = __monoid_op(__x, __x);
if ((__n & 1) != 0)
__result = __monoid_op(__result, __x);
__n >>= 1;
}
return __result;
}
}
template<typename _Tp, typename _Integer>
inline _Tp
__power(_Tp __x, _Integer __n)
{ return __power(__x, __n, std::multiplies<_Tp>()); }
// Alias for the internal name __power. Note that power is an extension,
// not part of the C++ standard.
template<typename _Tp, typename _Integer, typename _MonoidOperation>
inline _Tp
power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
{ return __power(__x, __n, __monoid_op); }
template<typename _Tp, typename _Integer>
inline _Tp
power(_Tp __x, _Integer __n)
{ return __power(__x, __n); }
// iota is not part of the C++ standard. It is an extension.
template<typename _ForwardIter, typename _Tp>
void
iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
{
// concept requirements
__glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter>)
__glibcpp_function_requires(_ConvertibleConcept<_Tp,
typename std::iterator_traits<_ForwardIter>::value_type>)
while (__first != __last)
*__first++ = __value++;
}
} // namespace __gnu_cxx
#endif /* _EXT_NUMERIC */
......@@ -51,6 +51,7 @@
#include <ext/algorithm> // For copy_n and lexicographical_compare_3way
#include <ext/memory> // For uninitialized_copy_n
#include <ext/numeric> // For power
namespace __gnu_cxx
{
......
......@@ -24,10 +24,12 @@
// subdirectory that are meant to be directly included.
#include <ext/algorithm>
#include <ext/functional>
#include <ext/hash_map>
#include <ext/hash_set>
#include <ext/iterator>
#include <ext/memory>
#include <ext/numeric>
#include <ext/rope>
#include <ext/slist>
......
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