dnl -------------------------------------------------------------
-dnl gcc 2.95 does not correctly implement the resolution of
-dnl defect report #45 to the C++ standard (see
+dnl gcc 2.95 as well as some other compilers do not correctly implement
+dnl the resolution of defect report #45 to the C++ standard (see
dnl http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#45).
dnl try to detect this, and set a flag correspondingly. in short,
dnl the DR says that this is allowed, since member classes are
+dnl -------------------------------------------------------------
+dnl gcc up to 3.3 won't accept the following code:
+dnl -----------------------------
+dnl template <typename> class X {
+dnl template <typename> class Y {};
+dnl
+dnl template <typename T>
+dnl template <typename>
+dnl friend class X<T>::Y;
+dnl };
+dnl
+dnl X<int> x;
+dnl -----------------------------
+dnl
+dnl They don't accept the X<T>::Y here, probably because the class is
+dnl not complete at this point. gcc3.4 gets it right, though. One
+dnl can work around by simply saying
+dnl template <typename> friend class Y;
+dnl but then icc doesn't understand this :-( So everyone's got a bug
+dnl here. Also, note that the standard says that Y is an implicit friend
+dnl of X, but again, many compiler don't implement this correctly, which
+dnl is why we have to do something like the above in the first place...
+dnl
+dnl Usage: DEAL_II_CHECK_NESTED_CLASS_TEMPL_FRIEND_BUG
+dnl
+dnl -------------------------------------------------------------
+AC_DEFUN(DEAL_II_CHECK_NESTED_CLASS_TEMPL_FRIEND_BUG, dnl
+[
+ AC_MSG_CHECKING(for nested template class friends bug)
+ AC_LANG(C++)
+ CXXFLAGS="$CXXFLAGSG"
+ AC_TRY_COMPILE(
+ [
+ template <typename> class X {
+ template <typename> class Y {};
+
+ template <typename T>
+ template <typename>
+ friend class X<T>::Y;
+ };
+
+ X<int> x;
+ ],
+ [],
+ [
+ AC_MSG_RESULT(no)
+ ],
+ [
+ AC_MSG_RESULT(yes. using workaround)
+ AC_DEFINE(DEAL_II_NESTED_CLASS_TEMPL_FRIEND_BUG, 1,
+ [Defined if the compiler does not understand friend
+ declarations for nested member classes when giving
+ a full class specification.])
+ ])
+])
+
+
+
dnl -------------------------------------------------------------
dnl Many compilers get this wrong (see Section 14.7.3.1, number (4)):
dnl ---------------------------------
_ACEOF
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+
+ echo "$as_me:$LINENO: checking for nested template class friends bug" >&5
+echo $ECHO_N "checking for nested template class friends bug... $ECHO_C" >&6
+ ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ CXXFLAGS="$CXXFLAGSG"
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+ template <typename> class X {
+ template <typename> class Y {};
+
+ template <typename T>
+ template <typename>
+ friend class X<T>::Y;
+ };
+
+ X<int> x;
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+ echo "$as_me:$LINENO: result: yes. using workaround" >&5
+echo "${ECHO_T}yes. using workaround" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define DEAL_II_NESTED_CLASS_TEMPL_FRIEND_BUG 1
+_ACEOF
+
+
fi
rm -f conftest.$ac_objext conftest.$ac_ext