aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-16 11:48:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-16 11:48:44 +0000
commit39005c38ee51c18fd89c81803ad3c230640868e4 (patch)
tree822fab6b209f9d3706951b25f4fd6be459142019
parentf66cbd26c252e4bc149af6de20b9c4f46234cb1e (diff)
downloadpaludis-39005c38ee51c18fd89c81803ad3c230640868e4.tar.gz
paludis-39005c38ee51c18fd89c81803ad3c230640868e4.tar.xz
Work around various stupid compiler bugs
-rw-r--r--configure.ac65
-rw-r--r--paludis/hashed_containers.cc2
-rw-r--r--paludis/hashed_containers.hh.in55
-rw-r--r--paludis/qualified_package_name.hh4
-rw-r--r--paludis/visitor.hh8
5 files changed, 121 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac
index db4dfc1..815687c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,38 @@ AC_PROG_RANLIB
AC_PROG_MAKE_SET
dnl }}}
+dnl {{{ check for partial specialisation of template classes
+AC_MSG_CHECKING([for compiler support for partial specialisation of template classes])
+AC_COMPILE_IFELSE([
+template <typename T_>
+struct S
+{
+ static const int s = 0;
+};
+
+template <typename T_>
+struct S<const T_>
+{
+};
+
+template <typename T_>
+struct S<const T_ &>
+{
+ static const int t = 0;
+};
+
+int main(int, char *[])
+{
+ return S<int &>::s + S<const int &>::t;
+}
+],
+ [AC_MSG_RESULT([yes])],
+ [
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Your C++ compiler doesn't compile C++ code])
+ ])
+dnl }}}
+
dnl {{{ check for basic_string and string::find_last_not_of
AC_MSG_CHECKING([for a sufficiently standard std::basic_string<>])
AC_COMPILE_IFELSE([
@@ -79,6 +111,7 @@ int main(int, char **)
AC_MSG_RESULT([no])
AC_MSG_ERROR([Your std::set<>::const_reverse_iterator is h0rked])
])
+dnl }}}
dnl {{{ check for broken std::deque<NoDefaultConstructor>
AC_MSG_CHECKING([for a usable std::deque<NoDefaultConstructor>])
@@ -104,7 +137,8 @@ dnl }}}
dnl {{{ check for hashes
have_tr1_hashes=0
have_ext_hashes=0
-AC_MSG_CHECKING([for a usable std::tr1::unordered_map<>])
+have_std_hashes=0
+AC_MSG_CHECKING([for hashed associative containers])
AC_COMPILE_IFELSE([
#include <tr1/unordered_map>
int main(int, char **)
@@ -114,12 +148,10 @@ int main(int, char **)
}
],
[
- AC_MSG_RESULT([yes])
+ AC_MSG_RESULT([std::tr1::unordered_map])
have_tr1_hashes=1
],
[
- AC_MSG_RESULT([no])
- AC_MSG_CHECKING([for a usable __gnu_cxx::hash_map<>])
AC_COMPILE_IFELSE([
#include <ext/hash_map>
int main(int, char **)
@@ -129,20 +161,35 @@ int main(int, char **)
}
],
[
- AC_MSG_RESULT([yes])
+ AC_MSG_RESULT([__gnu_cxx::hash_map])
have_ext_hashes=1
],
[
- AC_MSG_RESULT([no])
- ]
- ]))
+ AC_COMPILE_IFELSE([
+#include <hash_map>
+int main(int, char **)
+{
+ std::hash_map<int, int> m;
+ m.insert(std::make_pair(1, 2));
+}
+],
+ [
+ AC_MSG_RESULT([std::hash_map])
+ have_std_hashes=1
+ ],
+ [
+ AC_MSG_RESULT([no, falling back to std::map (slower)])
+ ])])])
HAVE_TR1_HASHES=$have_tr1_hashes
AC_DEFINE_UNQUOTED([HAVE_TR1_HASHES], $have_tr1_hashes, [Do we have std::tr1:: hashes?])
AC_SUBST([HAVE_TR1_HASHES])
HAVE_EXT_HASHES=$have_ext_hashes
-AC_DEFINE_UNQUOTED([HAVE_EXT_HASHES], $have_ext_hashes, [Do we have __gnu_cxx hashes?])
+AC_DEFINE_UNQUOTED([HAVE_EXT_HASHES], $have_ext_hashes, [Do we have __gnu_cxx:: hashes?])
AC_SUBST([HAVE_EXT_HASHES])
+HAVE_STD_HASHES=$have_std_hashes
+AC_DEFINE_UNQUOTED([HAVE_STD_HASHES], $have_std_hashes, [Do we have std:: hashes?])
+AC_SUBST([HAVE_STD_HASHES])
dnl }}}
dnl {{{ we need libebt.
diff --git a/paludis/hashed_containers.cc b/paludis/hashed_containers.cc
index 050ce8e..ffaa618 100644
--- a/paludis/hashed_containers.cc
+++ b/paludis/hashed_containers.cc
@@ -21,7 +21,7 @@
using namespace paludis;
-#if PALUDIS_HAVE_TR1_HASHES || PALUDIS_HAVE_EXT_HASHES
+#if PALUDIS_HAVE_TR1_HASHES || PALUDIS_HAVE_EXT_HASHES || PALUDIS_HAVE_STD_HASHES
std::size_t
CRCHash<QualifiedPackageName>::operator() (const QualifiedPackageName & val) const
diff --git a/paludis/hashed_containers.hh.in b/paludis/hashed_containers.hh.in
index 587d14b..5b82282 100644
--- a/paludis/hashed_containers.hh.in
+++ b/paludis/hashed_containers.hh.in
@@ -24,6 +24,7 @@
#define PALUDIS_HAVE_TR1_HASHES @HAVE_TR1_HASHES@
#define PALUDIS_HAVE_EXT_HASHES @HAVE_EXT_HASHES@
+#define PALUDIS_HAVE_STD_HASHES @HAVE_STD_HASHES@
#include <paludis/qualified_package_name.hh>
#include <paludis/version_spec.hh>
@@ -35,6 +36,9 @@
#elif PALUDIS_HAVE_EXT_HASHES
# include <ext/hash_set>
# include <ext/hash_map>
+#elif PALUDIS_HAVE_STD_HASHES
+# include <hash_set>
+# include <hash_map>
#else
# include <set>
# include <map>
@@ -63,6 +67,10 @@ namespace paludis
/// Our map type.
typedef __gnu_cxx::hash_map<Key_, Value_, CRCHash<Key_> > Type;
+#elif PALUDIS_HAVE_STD_HASHES
+ /// Our map type.
+ typedef std::hash_map<Key_, Value_, CRCHash<Key_> > Type;
+
#else
/// Our map type.
typedef std::map<Key_, Value_> Type;
@@ -83,13 +91,17 @@ namespace paludis
/// Our set type.
typedef __gnu_cxx::hash_set<Key_, CRCHash<Key_> > Type;
+#elif PALUDIS_HAVE_STD_HASHES
+ /// Our set type.
+ typedef std::hash_set<Key_, CRCHash<Key_> > Type;
+
#else
/// Our set type.
typedef std::set<Key_> Type;
#endif
};
-#if PALUDIS_HAVE_TR1_HASHES || PALUDIS_HAVE_EXT_HASHES
+#if PALUDIS_HAVE_TR1_HASHES || PALUDIS_HAVE_EXT_HASHES || PALUDIS_HAVE_STD_HASHES
namespace
{
/**
@@ -116,6 +128,19 @@ namespace paludis
public:
/// Hash function.
std::size_t operator() (const QualifiedPackageName & val) const;
+
+#if (! PALUDIS_HAVE_TR1_HASHES) && (! PALUDIS_HAVE_EXT_HASHES)
+ enum
+ {
+ min_buckets = 32,
+ bucket_size = 4
+ };
+
+ bool operator() (const QualifiedPackageName & i1, const QualifiedPackageName & i2) const
+ {
+ return i1 < i2;
+ }
+#endif
};
/**
@@ -129,6 +154,20 @@ namespace paludis
public:
/// Hash function.
std::size_t operator() (const Validated<std::string, Validated_> & val) const;
+
+#if (! PALUDIS_HAVE_TR1_HASHES) && (! PALUDIS_HAVE_EXT_HASHES)
+ enum
+ {
+ min_buckets = 32,
+ bucket_size = 4
+ };
+
+ bool operator() (const Validated<std::string, Validated_> i1,
+ const Validated<std::string, Validated_> & i2) const
+ {
+ return i1 < i2;
+ }
+#endif
};
/**
@@ -142,6 +181,20 @@ namespace paludis
public:
/// Hash function.
std::size_t operator() (const std::pair<QualifiedPackageName, VersionSpec> & val) const;
+
+#if (! PALUDIS_HAVE_TR1_HASHES) && (! PALUDIS_HAVE_EXT_HASHES)
+ enum
+ {
+ min_buckets = 32,
+ bucket_size = 4
+ };
+
+ bool operator() (const std::pair<QualifiedPackageName, VersionSpec> & i1,
+ const std::pair<QualifiedPackageName, VersionSpec> & i2) const
+ {
+ return i1 < i2;
+ }
+#endif
};
template <typename Validated_>
diff --git a/paludis/qualified_package_name.hh b/paludis/qualified_package_name.hh
index 6bf6964..037323a 100644
--- a/paludis/qualified_package_name.hh
+++ b/paludis/qualified_package_name.hh
@@ -124,8 +124,8 @@ namespace paludis
* Convenience operator to make a QualifiedPackageName from a
* PackageNamePart and a CategoryNamePart.
*/
- const QualifiedPackageName
- inline operator+ (const CategoryNamePart & c, const PackageNamePart & p)
+ inline const QualifiedPackageName
+ operator+ (const CategoryNamePart & c, const PackageNamePart & p)
{
return QualifiedPackageName(c, p);
}
diff --git a/paludis/visitor.hh b/paludis/visitor.hh
index efb84fc..2f73085 100644
--- a/paludis/visitor.hh
+++ b/paludis/visitor.hh
@@ -224,6 +224,10 @@ namespace paludis
public visitor_internals::Visits<typename visitor_internals::MakePointerToConst<N8_>::Type>,
public visitor_internals::Visits<typename visitor_internals::MakePointerToConst<N9_>::Type>
{
+ protected:
+ ~ConstVisitor()
+ {
+ }
};
/**
@@ -240,6 +244,10 @@ namespace paludis
public visitor_internals::Visits<N8_>,
public visitor_internals::Visits<N9_>
{
+ protected:
+ ~Visitor()
+ {
+ }
};
};