// GROUPS passed templates
// Test that the compiler will emit the definition of min given just
// the declaration. At one point in the past, it did not.
+// Special g++ Options: -fguiding-decls
#include <iostream.h>
template <class T> inline T min(T a, T b) { return (a < b) ? a : b;};
ostream& operator<< (const char *) { return *this; };
};
-template <class T> class foo {
- friend ostream& operator<<(ostream&, foo<T>&);
-};
+template <class T> class foo;
template <class T> ostream& operator<< (ostream& ios, foo<T>&obj) { };
+template <class T> class foo {
+ friend ostream& operator<<<>(ostream&, foo<T>&);
+};
+
int main()
{
ostream cout;
// Bug: g++ fails to actually instantiate templates to the specifications of
// guiding decls.
-// Special g++ Options: -g -ansi -pedantic-errors
+// Special g++ Options: -g -ansi -pedantic-errors -fguiding-decls
template <class T> inline T min (T a, T b) { return a<b?a:b; }
double min (double, double);
-// Special g++ Options: -fansi-overloading
+// Special g++ Options: -fguiding-decls
struct A {
friend int operator== (const A&, const A&);
// GROUPS passed templates
+// Special g++ Options: -fguiding-decls
extern "C" void printf (char *, ...);
template<class T> T max(T a, T b) { return a > b ? a : b; }
--- /dev/null
+// Build don't run:
+// GROUPS passed templates
+template <class T>
+void foo(T);
+
+class S {
+ friend void foo<>(int);
+
+ int i;
+};
+
+
+template <>
+void foo(int)
+{
+ S s;
+ s.i = 3;
+}
+
+
+int main()
+{
+ foo(3);
+}
--- /dev/null
+// Build don't run:
+// GROUPS passed templates
+class ostream {};
+
+template <class T>
+class S;
+
+template <class T>
+void operator<<(ostream&, S<T>) {}
+
+template <class T>
+class S
+{
+ friend void operator<<<>(ostream&, const S<T>);
+};
+
+
+int main()
+{
+ ostream o;
+
+ o << S<int>();
+}
template <class U>
void foo(char*, U);
- template <>
void foo(int i);
};
}
-template <>
void S::foo(int i)
{
printf ("int version\n");