aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-29 21:41:25 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-29 21:41:25 +0000
commit69ed7ec4664dcb819f082ac73169fbc4b0447542 (patch)
tree1e22f480e434a1f09fc684f99401813dc441689e
parent5618c8064eafe0fd6e677b9527779da1ea633edb (diff)
downloadpaludis-69ed7ec4664dcb819f082ac73169fbc4b0447542.tar.gz
paludis-69ed7ec4664dcb819f082ac73169fbc4b0447542.tar.xz
Allow tr1 functional
-rw-r--r--configure.ac53
-rw-r--r--tr1/Makefile.am45
-rw-r--r--tr1/tr1_functional.hh52
3 files changed, 134 insertions, 16 deletions
diff --git a/configure.ac b/configure.ac
index 5157443..109e9df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,6 +259,59 @@ int main(int, char *[])
AM_CONDITIONAL([NEED_TYPE_TRAITS_WRAPPERS], test x$need_type_traits_wrappers = "xyes")
dnl }}}
+dnl {{{ tr1 binders
+need_bind_wrappers=no
+AC_MSG_CHECKING([for std::tr1::bind<>])
+AC_COMPILE_IFELSE([
+#include <tr1/functional>
+#include <functional>
+#include <algorithm>
+#include <list>
+struct S
+{
+ void x(const int) const
+ {
+ }
+};
+int main(int, char *[])
+{
+ using namespace std::tr1::placeholders;
+ std::list<int> l;
+ S s;
+ std::for_each(l.begin(), l.end(),
+ std::tr1::bind(std::tr1::mem_fn(&S::x), &s, _1));
+}
+],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])
+ AC_MSG_CHECKING([for boost::bind<>])
+ AC_COMPILE_IFELSE([
+#include <boost/bind.hpp>
+#include <boost/mem_fn.hpp>
+#include <functional>
+#include <algorithm>
+#include <list>
+struct S
+{
+ void x(const int) const
+ {
+ }
+};
+int main(int, char *[])
+{
+ std::list<int> l;
+ S s;
+ std::for_each(l.begin(), l.end(),
+ boost::bind(boost::mem_fn(&S::x), &s, _1));
+}
+],
+ [AC_MSG_RESULT([yes])
+ need_bind_wrappers=yes],
+ [AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Your compiler doesn't support tr1 and boost is not installed])])])
+AM_CONDITIONAL([NEED_BIND_WRAPPERS], test x$need_bind_wrappers = "xyes")
+dnl }}}
+
need_xml_check=
need_pcrepp_check=
diff --git a/tr1/Makefile.am b/tr1/Makefile.am
index 83e5a19..eebe625 100644
--- a/tr1/Makefile.am
+++ b/tr1/Makefile.am
@@ -10,49 +10,62 @@ DEFS= \
paludis_compat_tr1dir = $(includedir)/paludis/compat/tr1
-paludis_compat_tr1_HEADERS = tr1_memory.hh tr1_type_traits.hh
+paludis_compat_tr1_HEADERS = tr1_memory.hh tr1_type_traits.hh tr1_functional.hh
if NEED_POINTER_WRAPPERS
-if NEED_TYPE_TRAITS_WRAPPERS
-nodist_paludis_compat_tr1_HEADERS = memory type_traits
-else
-nodist_paludis_compat_tr1_HEADERS = memory
-endif
-else
-if NEED_TYPE_TRAITS_WRAPPERS
-nodist_paludis_compat_tr1_HEADERS = type_traits
-else
-nodist_paludis_compat_tr1_HEADERS =
-endif
-endif
-if NEED_POINTER_WRAPPERS
+pointer_wrappers = memory
memory : tr1_memory.hh
cp $(srcdir)/tr1_memory.hh $@
else
+pointer_wrappers =
+
memory :
rm -f $@ || true
endif
if NEED_TYPE_TRAITS_WRAPPERS
+type_traits_wrappers = type_traits
type_traits : tr1_type_traits.hh
cp $(srcdir)/tr1_type_traits.hh $@
else
+type_traits_wrappers =
+
type_traits :
rm -f $@ || true
endif
+if NEED_BIND_WRAPPERS
+
+bind_wrappers = functional
+
+functional : tr1_functional.hh
+ cp $(srcdir)/tr1_functional.hh $@
+
+else
+
+bind_wrappers =
+
+functional :
+ rm -f $@ || true
+
+endif
+
+nodist_paludis_compat_tr1_HEADERS = \
+ $(pointer_wrappers) \
+ $(type_traits_wrappers) \
+ $(bind_wrappers)
-EXTRA_DIST = tr1_memory.hh tr1_type_traits.hh
-BUILT_SOURCES = memory type_traits
+EXTRA_DIST = tr1_memory.hh tr1_type_traits.hh tr1_functional.hh
+BUILT_SOURCES = memory type_traits functional
SUBDIRS = .
built-sources : $(BUILT_SOURCES)
diff --git a/tr1/tr1_functional.hh b/tr1/tr1_functional.hh
new file mode 100644
index 0000000..c9f1123
--- /dev/null
+++ b/tr1/tr1_functional.hh
@@ -0,0 +1,52 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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 program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_TR1_TR1_FUNCTIONAL_HH
+#define PALUDIS_GUARD_TR1_TR1_FUNCTIONAL_HH 1
+
+/*
+ * Used if we have boost but not std::tr1::bind<> etc.
+ */
+
+#include <boost/bind.hpp>
+#include <boost/mem_fn.hpp>
+
+namespace std
+{
+ namespace tr1
+ {
+ using boost::bind;
+ using boost::mem_fn;
+
+ namespace placeholders
+ {
+ using _1;
+ using _2;
+ using _3;
+ using _4;
+ using _5;
+ using _6;
+ using _7;
+ using _8;
+ using _9;
+ }
+ }
+}
+
+#endif