Commit 59cffcf6 by Doug Gregor

[multiple changes]

2005-03-31  Chris Jefferson  <chris@bubblescope.net>

        * include/tr1/tuple: Support iteration via tuple_iterate.h.
        * include/tr1/tuple_iterate.h: Iteration file for tuple.

2005-03-31  Douglas Gregor  <doug.gregor@gmail.com>

        * include/Makefile.am (tr1_headers): Add bind and mu repetition
        headers and reference_wrapper<> forwarding header.
        * include/Makefile.in: Regenerate.
        * include/tr1/bind_iterate.h: Implementation of function call
        operators for the function object returned from tr1::bind().
        * include/tr1/bind_repeat.h: Bind-specific repetition header,
        akin to include/tr1/repeat.h.
        * include/tr1/functional (_Mem_fn): Bug fix: declare result
member
        template for use with result_of.
        (is_bind_expression): New.
        (is_placeholder): New.
        (_Placeholder): New. Placeholder type for bind.
        (_Mu): New. Implementation detail of bind.
        (_Bind, _Bind_result): New. Function objects returned by bind.
        (_GLIBCXX_JOIN): New. Required to create bind placeholders.
        * include/tr1/functional_iterate.h (_Bind, _Bind_result, bind):
        New. Implementation of tr1::bind.
        * include/tr1/mu_iterate.h (_Mu): result template and operator()
        for the _Mu helper to bind.
        * include/tr1/ref_fwd.h (reference_wrapper): Forward declaration
        used by tuple header.
        (ref): Ditto.
        (cref): Ditto.
        * include/tr1/repeat.h: Add bind-specific repetition macros.
        * include/tr1/tuple: Use reference_wrapper forwarding header for
        initial definitions, then include <tr1/functional> at the end, to
        make the circular dependencies work.
        (tie): Support zero-argument tie() function.
        * testsuite/tr1/3_function_objects/bind/all_bound.cc: New test of
        bind() functionality with parameters bound.
        * testsuite/tr1/3_function_objects/bind/nested.cc: New test of
        nested bind() expressions.
        * testsuite/tr1/3_function_objects/bind/placeholders.cc: New test
        of bind() placeholders.
        * testsuite/tr1/3_function_objects/bind/ref.cc: New test of bind()
        with arguments bound via reference_wrapper<>.
        * scripts/gen_includers.pl: Generate the repetitive part of
	include/tr1/repeat.h.
	* scripts/gen_bind_includers.pl: Generate the repetitive part of
	include/tr1/bind_repeat.h.

From-SVN: r97361
parent c423ee0d
2005-03-31 Chris Jefferson <chris@bubblescope.net>
* include/tr1/tuple: Support iteration via tuple_iterate.h.
* include/tr1/tuple_iterate.h: Iteration file for tuple.
2005-03-31 Douglas Gregor <doug.gregor@gmail.com>
* include/Makefile.am (tr1_headers): Add bind and mu repetition
headers and reference_wrapper<> forwarding header.
* include/Makefile.in: Regenerate.
* include/tr1/bind_iterate.h: Implementation of function call
operators for the function object returned from tr1::bind().
* include/tr1/bind_repeat.h: Bind-specific repetition header,
akin to include/tr1/repeat.h.
* include/tr1/functional (_Mem_fn): Bug fix: declare result member
template for use with result_of.
(is_bind_expression): New.
(is_placeholder): New.
(_Placeholder): New. Placeholder type for bind.
(_Mu): New. Implementation detail of bind.
(_Bind, _Bind_result): New. Function objects returned by bind.
(_GLIBCXX_JOIN): New. Required to create bind placeholders.
* include/tr1/functional_iterate.h (_Bind, _Bind_result, bind):
New. Implementation of tr1::bind.
* include/tr1/mu_iterate.h (_Mu): result template and operator()
for the _Mu helper to bind.
* include/tr1/ref_fwd.h (reference_wrapper): Forward declaration
used by tuple header.
(ref): Ditto.
(cref): Ditto.
* include/tr1/repeat.h: Add bind-specific repetition macros.
* include/tr1/tuple: Use reference_wrapper forwarding header for
initial definitions, then include <tr1/functional> at the end, to
make the circular dependencies work.
(tie): Support zero-argument tie() function.
* testsuite/tr1/3_function_objects/bind/all_bound.cc: New test of
bind() functionality with parameters bound.
* testsuite/tr1/3_function_objects/bind/nested.cc: New test of
nested bind() expressions.
* testsuite/tr1/3_function_objects/bind/placeholders.cc: New test
of bind() placeholders.
* testsuite/tr1/3_function_objects/bind/ref.cc: New test of bind()
with arguments bound via reference_wrapper<>.
* scripts/gen_includers.pl: Generate the repetitive part of
include/tr1/repeat.h.
* scripts/gen_bind_includers.pl: Generate the repetitive part of
include/tr1/bind_repeat.h.
2005-03-30 Aaron W. LaFramboise <aaronavay62@aaronwl.com>
* testsuite/Makefile.am (CXX): Use ${SHELL}.
......
......@@ -228,13 +228,18 @@ tr1_srcdir = ${glibcxx_srcdir}/include/tr1
tr1_builddir = ./tr1
tr1_headers = \
${tr1_srcdir}/array \
${tr1_srcdir}/bind_repeat.h \
${tr1_srcdir}/bind_iterate.h \
${tr1_srcdir}/boost_shared_ptr.h \
${tr1_srcdir}/mu_iterate.h \
${tr1_srcdir}/functional \
${tr1_srcdir}/functional_iterate.h \
${tr1_srcdir}/memory \
${tr1_srcdir}/ref_fwd.h \
${tr1_srcdir}/ref_wrap_iterate.h \
${tr1_srcdir}/repeat.h \
${tr1_srcdir}/tuple \
${tr1_srcdir}/tuple_iterate.h \
${tr1_srcdir}/utility \
${tr1_srcdir}/type_traits \
${tr1_srcdir}/type_traits_fwd.h \
......
......@@ -447,13 +447,18 @@ tr1_srcdir = ${glibcxx_srcdir}/include/tr1
tr1_builddir = ./tr1
tr1_headers = \
${tr1_srcdir}/array \
${tr1_srcdir}/bind_repeat.h \
${tr1_srcdir}/bind_iterate.h \
${tr1_srcdir}/boost_shared_ptr.h \
${tr1_srcdir}/mu_iterate.h \
${tr1_srcdir}/functional \
${tr1_srcdir}/functional_iterate.h \
${tr1_srcdir}/memory \
${tr1_srcdir}/ref_fwd.h \
${tr1_srcdir}/ref_wrap_iterate.h \
${tr1_srcdir}/repeat.h \
${tr1_srcdir}/tuple \
${tr1_srcdir}/tuple_iterate.h \
${tr1_srcdir}/utility \
${tr1_srcdir}/type_traits \
${tr1_srcdir}/type_traits_fwd.h \
......
// TR1 functional -*- C++ -*-
// Copyright (C) 2005 Free Software Foundation, Inc.
// Written by Douglas Gregor <doug.gregor -at- gmail.com>
//
// 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.
/** @file bind_iterate.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
#if _GLIBCXX_BIND_NUM_ARGS > 0
template<_GLIBCXX_BIND_TEMPLATE_PARAMS>
#endif
#ifdef _GLIBCXX_BIND_HAS_RESULT_TYPE
result_type
#else
typename result_of<_Functor(_GLIBCXX_BIND_V_TEMPLATE_ARGS())>::type
#endif
operator()(_GLIBCXX_BIND_PARAMS)
{ return _M_f(_GLIBCXX_BIND_V_ARGS); }
#if _GLIBCXX_BIND_NUM_ARGS > 0
template<_GLIBCXX_BIND_TEMPLATE_PARAMS>
#endif
#ifdef _GLIBCXX_BIND_HAS_RESULT_TYPE
result_type
#else
typename result_of<const _Functor(_GLIBCXX_BIND_V_TEMPLATE_ARGS(const))>::type
#endif
operator()(_GLIBCXX_BIND_PARAMS) const
{ return _M_f(_GLIBCXX_BIND_V_ARGS); }
#if _GLIBCXX_BIND_NUM_ARGS > 0
template<_GLIBCXX_BIND_TEMPLATE_PARAMS>
#endif
#ifdef _GLIBCXX_BIND_HAS_RESULT_TYPE
result_type
#else
typename result_of<volatile _Functor(_GLIBCXX_BIND_V_TEMPLATE_ARGS(volatile))>::type
#endif
operator()(_GLIBCXX_BIND_PARAMS) volatile
{ return _M_f(_GLIBCXX_BIND_V_ARGS); }
#if _GLIBCXX_BIND_NUM_ARGS > 0
template<_GLIBCXX_BIND_TEMPLATE_PARAMS>
#endif
#ifdef _GLIBCXX_BIND_HAS_RESULT_TYPE
result_type
#else
typename result_of<const volatile _Functor(_GLIBCXX_BIND_V_TEMPLATE_ARGS(const volatile))>::type
#endif
operator()(_GLIBCXX_BIND_PARAMS) const volatile
{ return _M_f(_GLIBCXX_BIND_V_ARGS); }
// TR1 code repetition for bind -*- C++ -*-
// Copyright (C) 2005 Free Software Foundation, Inc.
// Written by Douglas Gregor <doug.gregor -at- gmail.com>
//
// 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.
/** @file bind_repeat.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
#ifndef _GLIBCXX_BIND_REPEAT_HEADER
# error Internal error: _GLIBCXX_BIND_REPEAT_HEADER must be set
#endif /* _GLIBCXX_BIND_REPEAT_HEADER */
#define _GLIBCXX_BIND_NUM_ARGS 0
#define _GLIBCXX_BIND_COMMA
#define _GLIBCXX_BIND_TEMPLATE_PARAMS
#define _GLIBCXX_BIND_TEMPLATE_ARGS
#define _GLIBCXX_BIND_PARAMS
#define _GLIBCXX_BIND_ARGS
# include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 1
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1
#define _GLIBCXX_BIND_PARAMS _U1& __u1
#define _GLIBCXX_BIND_ARGS __u1
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 2
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1, typename _U2
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1, _U2
#define _GLIBCXX_BIND_PARAMS _U1& __u1, _U2& __u2
#define _GLIBCXX_BIND_ARGS __u1, __u2
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 3
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1, typename _U2, typename _U3
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1, _U2, _U3
#define _GLIBCXX_BIND_PARAMS _U1& __u1, _U2& __u2, _U3& __u3
#define _GLIBCXX_BIND_ARGS __u1, __u2, __u3
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 4
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1, typename _U2, typename _U3, typename _U4
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1, _U2, _U3, _U4
#define _GLIBCXX_BIND_PARAMS _U1& __u1, _U2& __u2, _U3& __u3, _U4& __u4
#define _GLIBCXX_BIND_ARGS __u1, __u2, __u3, __u4
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 5
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1, typename _U2, typename _U3, typename _U4, typename _U5
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1, _U2, _U3, _U4, _U5
#define _GLIBCXX_BIND_PARAMS _U1& __u1, _U2& __u2, _U3& __u3, _U4& __u4, _U5& __u5
#define _GLIBCXX_BIND_ARGS __u1, __u2, __u3, __u4, __u5
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 6
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1, typename _U2, typename _U3, typename _U4, typename _U5, typename _U6
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1, _U2, _U3, _U4, _U5, _U6
#define _GLIBCXX_BIND_PARAMS _U1& __u1, _U2& __u2, _U3& __u3, _U4& __u4, _U5& __u5, _U6& __u6
#define _GLIBCXX_BIND_ARGS __u1, __u2, __u3, __u4, __u5, __u6
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 7
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1, typename _U2, typename _U3, typename _U4, typename _U5, typename _U6, typename _U7
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1, _U2, _U3, _U4, _U5, _U6, _U7
#define _GLIBCXX_BIND_PARAMS _U1& __u1, _U2& __u2, _U3& __u3, _U4& __u4, _U5& __u5, _U6& __u6, _U7& __u7
#define _GLIBCXX_BIND_ARGS __u1, __u2, __u3, __u4, __u5, __u6, __u7
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 8
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1, typename _U2, typename _U3, typename _U4, typename _U5, typename _U6, typename _U7, typename _U8
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8
#define _GLIBCXX_BIND_PARAMS _U1& __u1, _U2& __u2, _U3& __u3, _U4& __u4, _U5& __u5, _U6& __u6, _U7& __u7, _U8& __u8
#define _GLIBCXX_BIND_ARGS __u1, __u2, __u3, __u4, __u5, __u6, __u7, __u8
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 9
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1, typename _U2, typename _U3, typename _U4, typename _U5, typename _U6, typename _U7, typename _U8, typename _U9
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9
#define _GLIBCXX_BIND_PARAMS _U1& __u1, _U2& __u2, _U3& __u3, _U4& __u4, _U5& __u5, _U6& __u6, _U7& __u7, _U8& __u8, _U9& __u9
#define _GLIBCXX_BIND_ARGS __u1, __u2, __u3, __u4, __u5, __u6, __u7, __u8, __u9
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
#define _GLIBCXX_BIND_NUM_ARGS 10
#define _GLIBCXX_BIND_COMMA ,
#define _GLIBCXX_BIND_TEMPLATE_PARAMS typename _U1, typename _U2, typename _U3, typename _U4, typename _U5, typename _U6, typename _U7, typename _U8, typename _U9, typename _U10
#define _GLIBCXX_BIND_TEMPLATE_ARGS _U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10
#define _GLIBCXX_BIND_PARAMS _U1& __u1, _U2& __u2, _U3& __u3, _U4& __u4, _U5& __u5, _U6& __u6, _U7& __u7, _U8& __u8, _U9& __u9, _U10& __u10
#define _GLIBCXX_BIND_ARGS __u1, __u2, __u3, __u4, __u5, __u6, __u7, __u8, __u9, __u10
#include _GLIBCXX_BIND_REPEAT_HEADER
#undef _GLIBCXX_BIND_ARGS
#undef _GLIBCXX_BIND_PARAMS
#undef _GLIBCXX_BIND_TEMPLATE_ARGS
#undef _GLIBCXX_BIND_TEMPLATE_PARAMS
#undef _GLIBCXX_BIND_COMMA
#undef _GLIBCXX_BIND_NUM_ARGS
......@@ -40,6 +40,7 @@
#include <bits/cpp_type_traits.h>
#include <string> // for std::tr1::hash
#include <cstdlib> // for std::abort
#include <tr1/tuple>
namespace std
{
......@@ -452,6 +453,17 @@ namespace tr1
== sizeof(__check_const<_Tp>(__get_ref<_Tp>(), (_Tp*)0)))>
{ };
template<typename _Signature>
struct result;
template<typename _CVMem, typename _Tp>
struct result<_CVMem(_Tp)>
: public _Result_type<_Tp> { };
template<typename _CVMem, typename _Tp>
struct result<_CVMem(_Tp&)>
: public _Result_type<_Tp> { };
explicit _Mem_fn(_Res _Class::*__pm) : __pm(__pm) { }
// Handle objects
......@@ -491,6 +503,201 @@ namespace tr1
}
/**
* @brief Determines if the given type _Tp is a function object
* should be treated as a subexpression when evaluating calls to
* function objects returned by bind(). [TR1 3.6.1]
*/
template<typename _Tp>
struct is_bind_expression
{
static const bool value = false;
};
/**
* @brief Determines if the given type _Tp is a placeholder in a
* bind() expression and, if so, which placeholder it is. [TR1 3.6.2]
*/
template<typename _Tp>
struct is_placeholder
{
static const int value = 0;
};
/**
* @if maint
* The type of placeholder objects defined by libstdc++.
* @endif
*/
template<int _Num> struct _Placeholder { };
/**
* @if maint
* Partial specialization of is_placeholder that provides the placeholder
* number for the placeholder objects defined by libstdc++.
* @endif
*/
template<int _Num>
struct is_placeholder<_Placeholder<_Num> >
{
static const int value = _Num;
};
/**
* @if maint
* Maps an argument to bind() into an actual argument to the bound
* function object [TR1 3.6.3/5]. Only the first parameter should
* be specified: the rest are used to determine among the various
* implementations. Note that, although this class is a function
* object, isn't not entirely normal because it takes only two
* parameters regardless of the number of parameters passed to the
* bind expression. The first parameter is the bound argument and
* the second parameter is a tuple containing references to the
* rest of the arguments.
* @endif
*/
template<typename _Arg,
bool _IsBindExp = is_bind_expression<_Arg>::value,
bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>
class _Mu;
/**
* @if maint
* If the argument is reference_wrapper<_Tp>, returns the
* underlying reference. [TR1 3.6.3/5 bullet 1]
* @endif
*/
template<typename _Tp>
class _Mu<reference_wrapper<_Tp>, false, false>
{
public:
typedef _Tp& result_type;
/* Note: This won't actually work for const volatile
* reference_wrappers, because reference_wrapper::get() is const
* but not volatile-qualified. This might be a defect in the TR.
*/
template<typename _CVRef, typename _Tuple>
result_type
operator()(_CVRef& __arg, const _Tuple&) const volatile
{ return __arg.get(); }
};
/**
* @if maint
* If the argument is a bind expression, we invoke the underlying
* function object with the same cv-qualifiers as we are given and
* pass along all of our arguments (unwrapped). [TR1 3.6.3/5 bullet 2]
* @endif
*/
template<typename _Arg>
class _Mu<_Arg, true, false>
{
public:
template<typename _Signature> class result;
#define _GLIBCXX_REPEAT_HEADER <tr1/mu_iterate.h>
# include <tr1/repeat.h>
#undef _GLIBCXX_REPEAT_HEADER
};
/**
* @if maint
* If the argument is a placeholder for the Nth argument, returns
* a reference to the Nth argument to the bind function object.
* [TR1 3.6.3/5 bullet 3]
* @endif
*/
template<typename _Arg>
class _Mu<_Arg, false, true>
{
public:
template<typename _Signature> class result;
template<typename _CVMu, typename _CVArg, typename _Tuple>
class result<_CVMu(_CVArg, _Tuple)>
{
// Add a reference, if it hasn't already been done for us.
// This allows us to be a little bit sloppy in constructing
// the tuple that we pass to result_of<...>.
typedef typename tuple_element<(is_placeholder<_Arg>::value - 1),
_Tuple>::type __base_type;
public:
typedef typename add_reference<__base_type>::type type;
};
template<typename _Tuple>
typename result<_Mu(_Arg, _Tuple)>::type
operator()(const volatile _Arg&, const _Tuple& __tuple) const volatile
{
return ::std::tr1::get<(is_placeholder<_Arg>::value - 1)>(__tuple);
}
};
/**
* @if maint
* If the argument is just a value, returns a reference to that
* value. The cv-qualifiers on the reference are the same as the
* cv-qualifiers on the _Mu object. [TR1 3.6.3/5 bullet 4]
* @endif
*/
template<typename _Arg>
class _Mu<_Arg, false, false>
{
public:
template<typename _Signature> struct result;
template<typename _CVMu, typename _CVArg, typename _Tuple>
struct result<_CVMu(_CVArg, _Tuple)>
{
typedef typename add_reference<_CVArg>::type type;
};
// Pick up the cv-qualifiers of the argument
template<typename _CVArg, typename _Tuple>
_CVArg& operator()(_CVArg& __arg, const _Tuple&) const volatile
{ return __arg; }
};
/**
* @if maint
* Type of the function object returned from bind().
* @endif
*/
template<typename _Signature>
struct _Bind;
/**
* @if maint
* Type of the function object returned from bind<R>().
* @endif
*/
template<typename _Result, typename _Signature>
struct _Bind_result;
/**
* @if maint
* Class template _Bind is always a bind expression.
* @endif
*/
template<typename _Signature>
struct is_bind_expression<_Bind<_Signature> >
{
static const bool value = true;
};
/**
* @if maint
* Class template _Bind_result is always a bind expression.
* @endif
*/
template<typename _Result, typename _Signature>
struct is_bind_expression<_Bind_result<_Result, _Signature> >
{
static const bool value = true;
};
/**
* @brief Exception class thrown when class template function's
* operator() is called with an empty target.
*
......@@ -845,9 +1052,15 @@ namespace tr1
__x.swap(__y);
}
#define _GLIBCXX_JOIN(X,Y) _GLIBCXX_JOIN2( X , Y )
#define _GLIBCXX_JOIN2(X,Y) _GLIBCXX_JOIN3(X,Y)
#define _GLIBCXX_JOIN3(X,Y) X##Y
#define _GLIBCXX_REPEAT_HEADER <tr1/functional_iterate.h>
#include <tr1/repeat.h>
#undef _GLIBCXX_REPEAT_HEADER
#undef _GLIBCXX_JOIN3
#undef _GLIBCXX_JOIN2
#undef _GLIBCXX_JOIN
// Definition of default hash function std::tr1::hash<>. The types for
// which std::tr1::hash<T> is defined is in clause 6.3.3. of the PDTR.
......
......@@ -28,7 +28,7 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file function_iterate.h
/** @file functional_iterate.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
......@@ -390,7 +390,101 @@ template<typename _Res, typename _Class _GLIBCXX_COMMA_SHIFTED
};
#endif
template<typename _Signature, typename _Functor> class _Function_handler;
#if _GLIBCXX_NUM_ARGS > 0
namespace placeholders
{
namespace
{
_Placeholder<_GLIBCXX_NUM_ARGS> _GLIBCXX_JOIN(_,_GLIBCXX_NUM_ARGS);
}
}
#endif
template<typename _Functor _GLIBCXX_COMMA _GLIBCXX_TEMPLATE_PARAMS>
class _Bind<_Functor(_GLIBCXX_TEMPLATE_ARGS)>
: public _Weak_result_type<_Functor>
{
typedef _Bind __self_type;
_Functor _M_f;
_GLIBCXX_BIND_MEMBERS
public:
#if _GLIBCXX_NUM_ARGS == 0
explicit
#endif
_Bind(_Functor __f _GLIBCXX_COMMA _GLIBCXX_PARAMS)
: _M_f(__f) _GLIBCXX_COMMA _GLIBCXX_BIND_MEMBERS_INIT { }
#define _GLIBCXX_BIND_REPEAT_HEADER <tr1/bind_iterate.h>
#include <tr1/bind_repeat.h>
#undef _GLIBCXX_BIND_REPEAT_HEADER
};
template<typename _Result, typename _Functor
_GLIBCXX_COMMA _GLIBCXX_TEMPLATE_PARAMS>
class _Bind_result<_Result, _Functor(_GLIBCXX_TEMPLATE_ARGS)>
{
_Functor _M_f;
_GLIBCXX_BIND_MEMBERS
public:
typedef _Result result_type;
#if _GLIBCXX_NUM_ARGS == 0
explicit
#endif
_Bind_result(_Functor __f _GLIBCXX_COMMA _GLIBCXX_PARAMS)
: _M_f(__f) _GLIBCXX_COMMA _GLIBCXX_BIND_MEMBERS_INIT { }
#define _GLIBCXX_BIND_REPEAT_HEADER <tr1/bind_iterate.h>
#define _GLIBCXX_BIND_HAS_RESULT_TYPE
#include <tr1/bind_repeat.h>
#undef _GLIBCXX_BIND_HAS_RESULT_TYPE
#undef _GLIBCXX_BIND_REPEAT_HEADER
};
// Handle member pointers
template<typename _Tp, typename _Class _GLIBCXX_COMMA _GLIBCXX_TEMPLATE_PARAMS>
inline _Bind<_Mem_fn<_Tp _Class::*>(_GLIBCXX_TEMPLATE_ARGS)>
bind(_Tp _Class::* __pm _GLIBCXX_COMMA _GLIBCXX_PARAMS)
{
typedef _Bind<_Mem_fn<_Tp _Class::*>(_GLIBCXX_TEMPLATE_ARGS)> __result_type;
return __result_type(_Mem_fn<_Tp _Class::*>(__pm)
_GLIBCXX_COMMA _GLIBCXX_ARGS);
}
template<typename _Result, typename _Tp, typename _Class
_GLIBCXX_COMMA _GLIBCXX_TEMPLATE_PARAMS>
inline _Bind_result<_Result, _Mem_fn<_Tp _Class::*>(_GLIBCXX_TEMPLATE_ARGS)>
bind(_Tp _Class::* __pm _GLIBCXX_COMMA _GLIBCXX_PARAMS)
{
typedef _Bind_result<_Result, _Mem_fn<_Tp _Class::*>(_GLIBCXX_TEMPLATE_ARGS)>
__result_type;
return __result_type(_Mem_fn<_Tp _Class::*>(__pm)
_GLIBCXX_COMMA _GLIBCXX_ARGS);
}
// Handle arbitrary function objects
template<typename _Functor _GLIBCXX_COMMA _GLIBCXX_TEMPLATE_PARAMS>
inline _Bind<_Functor(_GLIBCXX_TEMPLATE_ARGS)>
bind(_Functor __f _GLIBCXX_COMMA _GLIBCXX_PARAMS)
{
typedef _Bind<_Functor(_GLIBCXX_TEMPLATE_ARGS)> __result_type;
return __result_type(__f _GLIBCXX_COMMA _GLIBCXX_ARGS);
}
template<typename _Result, typename _Functor
_GLIBCXX_COMMA _GLIBCXX_TEMPLATE_PARAMS>
inline
typename __enable_if<_Bind_result<_Result, _Functor(_GLIBCXX_TEMPLATE_ARGS)>,
!is_member_pointer<_Functor>::value>::__type
bind(_Functor __f _GLIBCXX_COMMA _GLIBCXX_PARAMS)
{
typedef _Bind_result<_Result, _Functor(_GLIBCXX_TEMPLATE_ARGS)>
__result_type;
return __result_type(__f _GLIBCXX_COMMA _GLIBCXX_ARGS);
}
template<typename _Res, typename _Functor _GLIBCXX_COMMA
_GLIBCXX_TEMPLATE_PARAMS>
......
// TR1 functional -*- C++ -*-
// Copyright (C) 2005 Free Software Foundation, Inc.
// Written by Douglas Gregor <doug.gregor -at- gmail.com>
//
// 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.
/** @file mu_iterate.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
// Determine the result type when we pass the arguments along. This
// involves passing along the cv-qualifiers placed on _Mu and
// unwrapping the argument bundle.
template<typename _CVMu, typename _CVArg
_GLIBCXX_COMMA _GLIBCXX_TEMPLATE_PARAMS>
class result<_CVMu(_CVArg, tuple<_GLIBCXX_TEMPLATE_ARGS>)>
: public result_of<_CVArg(_GLIBCXX_TEMPLATE_ARGS)> { };
template<typename _CVArg _GLIBCXX_COMMA _GLIBCXX_TEMPLATE_PARAMS>
typename result_of<_CVArg(_GLIBCXX_TEMPLATE_ARGS)>::type
operator()(_CVArg& __arg, const tuple<_GLIBCXX_TEMPLATE_ARGS>& __tuple)
const volatile
{
return __arg(_GLIBCXX_MU_GET_TUPLE_ARGS);
}
// class template reference_wrapper forwarding header -*- C++ -*-
// Copyright (C) 2004, 2005 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.
/** @file ref_fwd.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
// Douglas Gregor <doug.gregor -at- gmail.com>
#ifndef _TR1_REF_FWD
#define _TR1_REF_FWD
namespace std
{
namespace tr1
{
template<typename _Tp>
class reference_wrapper;
template<typename _Tp>
reference_wrapper<_Tp>
ref(_Tp& __t);
// Denotes a const reference should be taken to a variable.
template<typename _Tp>
reference_wrapper<const _Tp>
cref(const _Tp& __t);
}
}
#endif
// class template tuple -*- C++ -*-
// Copyright (C) 2004, 2005 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.
/** @file
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
// Chris Jefferson <chris@bubblescope.net>
/// @brief class tuple_size
template<_GLIBCXX_TEMPLATE_PARAMS>
struct tuple_size<tuple<_GLIBCXX_TEMPLATE_ARGS> >
{ static const int value = _GLIBCXX_NUM_ARGS; };
template<_GLIBCXX_TEMPLATE_PARAMS>
#ifdef _GLIBCXX_LAST_INCLUDE
class tuple
#else
class tuple<_GLIBCXX_TEMPLATE_ARGS>
#endif
{
_GLIBCXX_BIND_MEMBERS
public:
tuple()
{ }
#if _GLIBCXX_NUM_ARGS == 2
template<class _U1, class _U2>
tuple(const std::pair<_U1, _U2>& __u):
_M_arg1(__u.first), _M_arg2(__u.second)
{ }
#endif
#if _GLIBCXX_NUM_ARGS > 0
explicit tuple(_GLIBCXX_TUPLE_ADD_CREF) :
_GLIBCXX_BIND_MEMBERS_INIT
{ }
template<_GLIBCXX_TEMPLATE_PARAMS_U>
tuple(const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __in) :
_GLIBCXX_TUPLE_COPY_INIT
{ }
template<_GLIBCXX_TEMPLATE_PARAMS_U>
tuple&
operator=(const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __in)
{
_GLIBCXX_TUPLE_ASSIGN
return *this;
}
tuple(const tuple& __in) :
_GLIBCXX_TUPLE_COPY_INIT
{ }
#else
tuple(const tuple& __in)
{ }
#endif
tuple&
operator=(const tuple& __in)
{
_GLIBCXX_TUPLE_ASSIGN
return *this;
}
template<int __i, typename __Type>
friend class __get_helper;
template<typename, typename, typename, typename, typename,
typename, typename, typename, typename, typename>
friend class tuple;
};
#ifndef _GLIBCXX_LAST_INCLUDE
template<typename _Tp>
struct __get_helper<_GLIBCXX_NUM_ARGS, _Tp>
{
static typename __add_ref<typename tuple_element<_GLIBCXX_NUM_ARGS,
_Tp>::type>::type
get_value(_Tp& __in)
{ return __in._GLIBCXX_CAT(_M_arg,_GLIBCXX_NUM_ARGS_PLUS_1); }
static typename __add_c_ref<typename tuple_element<_GLIBCXX_NUM_ARGS,
_Tp>::type>::type
get_value(const _Tp& __in)
{ return __in._GLIBCXX_CAT(_M_arg,_GLIBCXX_NUM_ARGS_PLUS_1); }
};
/// @brief class tuple_element
template<typename _T1, typename _T2, typename _T3, typename _T4,
typename _T5, typename _T6, typename _T7, typename _T8,
typename _T9, typename _T10>
struct tuple_element<_GLIBCXX_NUM_ARGS, tuple<_T1, _T2, _T3, _T4,
_T5, _T6, _T7, _T8, _T9,
_T10> >
{ typedef _GLIBCXX_CAT(_T,_GLIBCXX_NUM_ARGS_PLUS_1) type; };
#endif
#if _GLIBCXX_NUM_ARGS == 0
tuple<>
inline make_tuple()
{ return tuple<>(); }
inline tuple<>
tie()
{ return tuple<>(); }
#else
template<_GLIBCXX_TEMPLATE_PARAMS>
typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::__type
make_tuple(_GLIBCXX_PARAMS)
{
return typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::
__type(_GLIBCXX_ARGS);
}
template<_GLIBCXX_TEMPLATE_PARAMS>
tuple<_GLIBCXX_REF_TEMPLATE_ARGS>
tie(_GLIBCXX_REF_PARAMS)
{ return make_tuple(_GLIBCXX_REF_WRAP_PARAMS); }
#endif
#!/usr/bin/perl -w
use English;
$max = shift @ARGV;
$template_params = "typename _U1";
$template_args = "_U1";
$params = "_U1& __u1";
$args = "__u1";
for ($num_args = 2; $num_args <= $max; ++$num_args) {
$template_params .= ", typename _U$num_args";
$template_args .= ", _U$num_args";
$params .= ", _U$num_args& __u$num_args";
$args .= ", __u$num_args";
print "#define _GLIBCXX_BIND_NUM_ARGS $num_args\n";
print "#define _GLIBCXX_BIND_COMMA ,\n";
print "#define _GLIBCXX_BIND_TEMPLATE_PARAMS $template_params\n";
print "#define _GLIBCXX_BIND_TEMPLATE_ARGS $template_args\n";
print "#define _GLIBCXX_BIND_PARAMS $params\n";
print "#define _GLIBCXX_BIND_ARGS $args\n";
print "#include _GLIBCXX_BIND_REPEAT_HEADER\n";
print "#undef _GLIBCXX_BIND_ARGS\n";
print "#undef _GLIBCXX_BIND_PARAMS\n";
print "#undef _GLIBCXX_BIND_TEMPLATE_ARGS\n";
print "#undef _GLIBCXX_BIND_TEMPLATE_PARAMS\n";
print "#undef _GLIBCXX_BIND_COMMA\n";
print "#undef _GLIBCXX_BIND_NUM_ARGS\n";
print "\n";
}
#!/usr/bin/perl -w
use English;
$max = shift @ARGV;
$template_params = "typename _T1";
$template_args = "_T1";
$params = "_T1 __a1";
$ref_params = "_T1& __a1";
$args = "__a1";
$bind_members = "_T1 _M_arg1;";
$bind_members_init = "_M_arg1(__a1)";
$mu_get_tuple_args = "::std::tr1::get<0>(__tuple)";
$bind_v_template_args = "typename result_of<_Mu<_T1> _CV(_T1, tuple<_GLIBCXX_BIND_TEMPLATE_ARGS>)>::type";
$bind_v_args = "_Mu<_T1>()(_M_arg1, ::std::tr1::tie(_GLIBCXX_BIND_ARGS))";
$tuple_add_cref = "typename __add_c_ref<_T1>::type __a1";
$tuple_copy_init = "_M_arg1(__in._M_arg1)";
$tuple_assign = "_M_arg1 = __in._M_arg1;";
$template_params_u = "typename _U1";
$template_args_u = "_U1";
$ref_wrap_params = "ref(__a1)";
$ref_template_args = "_T1&";
for ($num_args = 2; $num_args <= $max; ++$num_args) {
$prev_args = $num_args - 1;
$next_args = $num_args + 1;
$template_params_shifted = $template_params;
$template_args_shifted = $template_args;
$params_shifted = $params;
$args_shifted = $args;
$template_params .= ", typename _T$num_args";
$template_args .= ", _T$num_args";
$params .= ", _T$num_args __a$num_args";
$ref_params .=", _T$num_args& __a$num_args";
$args .= ", __a$num_args";
$bind_members .= " _T$num_args _M_arg$num_args;";
$bind_members_init .= ", _M_arg$num_args(__a$num_args)";
$mu_get_tuple_args .= ", ::std::tr1::get<$prev_args>(__tuple)";
$bind_v_template_args .= ", typename result_of<_Mu<_T$num_args> _CV(_T$num_args, tuple<_GLIBCXX_BIND_TEMPLATE_ARGS>)>::type";
$bind_v_args .= ", _Mu<_T$num_args>()(_M_arg$num_args, ::std::tr1::tie(_GLIBCXX_BIND_ARGS))";
$tuple_add_cref .= ", typename __add_c_ref<_T$num_args>::type __a$num_args";
$tuple_copy_init .= ", _M_arg$num_args(__in._M_arg$num_args)";
$tuple_assign .= " _M_arg$num_args = __in._M_arg$num_args;";
$template_params_u .= ", typename _U$num_args";
$template_args_u .= ", _U$num_args";
$ref_wrap_params .= ", ref(__a$num_args)";
$ref_template_args .= ", _T$num_args&";
print "#define _GLIBCXX_NUM_ARGS $num_args\n";
print "#define _GLIBCXX_COMMA ,\n";
print "#define _GLIBCXX_TEMPLATE_PARAMS $template_params\n";
print "#define _GLIBCXX_TEMPLATE_ARGS $template_args\n";
print "#define _GLIBCXX_PARAMS $params\n";
print "#define _GLIBCXX_REF_PARAMS $ref_params\n";
print "#define _GLIBCXX_ARGS $args\n";
print "#define _GLIBCXX_COMMA_SHIFTED ,\n";
print "#define _GLIBCXX_TEMPLATE_PARAMS_SHIFTED $template_params_shifted\n";
print "#define _GLIBCXX_TEMPLATE_ARGS_SHIFTED $template_args_shifted\n";
print "#define _GLIBCXX_PARAMS_SHIFTED $params_shifted\n";
print "#define _GLIBCXX_ARGS_SHIFTED $args_shifted\n";
print "#define _GLIBCXX_BIND_MEMBERS $bind_members\n";
print "#define _GLIBCXX_BIND_MEMBERS_INIT $bind_members_init\n";
print "#define _GLIBCXX_MU_GET_TUPLE_ARGS $mu_get_tuple_args\n";
print "#define _GLIBCXX_BIND_V_TEMPLATE_ARGS(_CV) $bind_v_template_args\n";
print "#define _GLIBCXX_BIND_V_ARGS $bind_v_args\n";
print "#define _GLIBCXX_TUPLE_ADD_CREF $tuple_add_cref\n";
print "#define _GLIBCXX_TUPLE_COPY_INIT $tuple_copy_init\n";
print "#define _GLIBCXX_TUPLE_ASSIGN $tuple_assign\n";
print "#define _GLIBCXX_TEMPLATE_PARAMS_U $template_params_u\n";
print "#define _GLIBCXX_TEMPLATE_ARGS_U $template_args_u\n";
print "#define _GLIBCXX_REF_WRAP_PARAMS $ref_wrap_params\n";
print "#define _GLIBCXX_REF_TEMPLATE_ARGS $ref_template_args\n";
print "#define _GLIBCXX_NUM_ARGS_PLUS_1 $next_args\n";
if ($num_args == $max) {
print "#define _GLIBCXX_LAST_INCLUDE\n"
}
print "#include _GLIBCXX_REPEAT_HEADER\n";
if ($num_args == $max) {
print "#undef _GLIBCXX_LAST_INCLUDE\n"
}
print "#undef _GLIBCXX_NUM_ARGS_PLUS_1\n";
print "#undef _GLIBCXX_REF_TEMPLATE_ARGS\n";
print "#undef _GLIBCXX_REF_WRAP_PARAMS\n";
print "#undef _GLIBCXX_TEMPLATE_ARGS_U\n";
print "#undef _GLIBCXX_TEMPLATE_PARAMS_U\n";
print "#undef _GLIBCXX_TUPLE_ASSIGN\n";
print "#undef _GLIBCXX_TUPLE_COPY_INIT\n";
print "#undef _GLIBCXX_TUPLE_ADD_CREF\n";
print "#undef _GLIBCXX_BIND_V_ARGS\n";
print "#undef _GLIBCXX_BIND_V_TEMPLATE_ARGS\n";
print "#undef _GLIBCXX_MU_GET_TUPLE_ARGS\n";
print "#undef _GLIBCXX_BIND_MEMBERS_INIT\n";
print "#undef _GLIBCXX_BIND_MEMBERS\n";
print "#undef _GLIBCXX_ARGS_SHIFTED\n";
print "#undef _GLIBCXX_PARAMS_SHIFTED\n";
print "#undef _GLIBCXX_TEMPLATE_ARGS_SHIFTED\n";
print "#undef _GLIBCXX_TEMPLATE_PARAMS_SHIFTED\n";
print "#undef _GLIBCXX_COMMA_SHIFTED\n";
print "#undef _GLIBCXX_ARGS\n";
print "#undef _GLIBCXX_REF_PARAMS\n";
print "#undef _GLIBCXX_PARAMS\n";
print "#undef _GLIBCXX_TEMPLATE_ARGS\n";
print "#undef _GLIBCXX_TEMPLATE_PARAMS\n";
print "#undef _GLIBCXX_COMMA\n";
print "#undef _GLIBCXX_NUM_ARGS\n";
print "\n";
}
......@@ -121,18 +121,18 @@ namespace __gnu_test
{ operator int() const; };
class AbstractClass
{
{
virtual void rotate(int) = 0;
virtual ~AbstractClass();
};
class PolymorphicClass
{
{
virtual void rotate(int);
virtual ~PolymorphicClass();
};
class DerivedPolymorphic : public PolymorphicClass { };
class DerivedPolymorphic : public PolymorphicClass { };
union UnionType { };
......@@ -151,14 +151,14 @@ namespace __gnu_test
{
++live_objects;
}
~do_truncate_float_t()
{
--live_objects;
}
int operator()(float x) { return (int)x; }
static int live_objects;
};
......@@ -182,21 +182,21 @@ namespace __gnu_test
}
long operator()(double x) { return (long)x; }
static int live_objects;
};
int do_truncate_double_t::live_objects = 0;
struct X
{
int bar;
int foo() { return 1; }
int foo_c() const { return 2; }
int foo_v() volatile { return 3; }
int foo_cv() const volatile { return 4; }
};
}; // namespace __gnu_test
} // namespace __gnu_test
#endif // _GLIBCXX_TESTSUITE_TR1_H
// 2005-03-20 Douglas Gregor <doug.gregor -at- gmail.com>
//
// Copyright (C) 2005 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.
// 3.6 function object binders
#include <tr1/functional>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
using namespace __gnu_test;
bool test __attribute__((unused)) = true;
// Operations on empty function<> objects
void test01()
{
using std::tr1::bind;
VERIFY( bind(std::plus<int>(), 3, 5)() == 8 );
VERIFY( bind(std::minus<int>(), 3, 5)() == -2 );
VERIFY( bind<int>(std::plus<int>(), 3, 5)() == 8 );
VERIFY( bind<int>(std::minus<int>(), 3, 5)() == -2 );
}
int main()
{
test01();
return 0;
}
// 2005-03-20 Douglas Gregor <doug.gregor -at- gmail.com>
//
// Copyright (C) 2005 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.
// 3.6 function object binders
#include <tr1/functional>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
using namespace __gnu_test;
bool test __attribute__((unused)) = true;
// Operations on empty function<> objects
void test01()
{
using std::tr1::bind;
using namespace std::tr1::placeholders;
int five = 5;
int seven = 7;
VERIFY( bind(std::multiplies<int>(), _1, bind(std::minus<int>(), 6, _2))(five, seven) == -5 );
VERIFY( bind(std::multiplies<int>(), _1, bind(std::minus<int>(), 6, _2))(seven, five) == 7 );
}
int main()
{
test01();
return 0;
}
// 2005-03-20 Douglas Gregor <doug.gregor -at- gmail.com>
//
// Copyright (C) 2005 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.
// 3.6 function object binders
#include <tr1/functional>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
using namespace __gnu_test;
bool test __attribute__((unused)) = true;
// Operations on empty function<> objects
void test01()
{
using std::tr1::bind;
using namespace std::tr1::placeholders;
int five = 5;
int seven = 7;
VERIFY( bind(std::minus<int>(), _1, _2)(five, seven) == -2 );
VERIFY( bind(std::minus<int>(), _2, _1)(five, seven) == 2 );
}
int main()
{
test01();
return 0;
}
// 2005-03-20 Douglas Gregor <doug.gregor -at- gmail.com>
//
// Copyright (C) 2005 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.
// 3.6 function object binders
#include <tr1/functional>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
using namespace __gnu_test;
bool test __attribute__((unused)) = true;
struct X
{
X() : bar(17) {}
int foo(int x, int y) { return bar + x + y; }
int bar;
private:
X(const X&);
X& operator=(const X&);
};
// Operations on empty function<> objects
void test01()
{
using std::tr1::bind;
using std::tr1::ref;
::X x;
VERIFY( bind(&::X::foo, ref(x), 1, 2)() == 20 );
VERIFY( bind<int>(&::X::foo, ref(x), 1, 2)() == 20 );
VERIFY( bind(&::X::bar, ref(x))() == 17 );
VERIFY( bind<int>(&::X::bar, ref(x))() == 17 );
}
int main()
{
test01();
return 0;
}
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