// Build don't link: // by Alexandre Oliva // I'm not 100% sure this program is correct, but g++ shouldn't just // crash. // The idea is to give privileged access to bar only to // specializations foo, for all B. template void foo(); template class bar { int i; // ERROR - private template friend void foo(); // ERROR - bogus declaration }; template void foo() { bar baz; baz.i = 1; // ERROR - foo cannot access bar::i bar buz; buz.i = 1; // ERROR - foo cannot access bar::i } int main() { foo(); foo(); }