I was trying to compile the following code for the classic copy&swap idiom on my Mac with clang 3.3
template class node{
private:
I believe that this is what you want (which happens to be what you just added to your question as the third option)
#include
template class node;
template void swap(node & a, node & b);
template class node {
private:
node* left;
node* right;
T value;
public:
friend void swap<>(node&, node&);
};
template void swap(node & a, node & b) {
std::swap(a.left, b.left);
std::swap(a.right, b.right);
std::swap(a.value, b.value);
}
int main() {
node x, y;
swap(x, y);
}