After reading this article Storing C++ template function definitions in a .CPP file, I know that the definition of a class that uses template has to be written in the header fil
The details of the template implementation will be visible. You can provide explicit template instantiations if you know which parameters will be necessary, however. But to be a generic solution, you have to provide the implementation so it can be used with other parameters.
No, you don't have to release it as open source. Just because someone can see the code, doesn't mean it has to be open source. You can license it almost however you want, and the purchaser has to abide by those rules. After all, just because we can see the entire text of a novel doesn't mean we can do whatever we want with it.
It does mean that template-based libraries normally have supply source code, yes. That isn't particularly similar to how "open source" is typically used. Then again, most good libraries supply source code in any case.
Yes, template-based C++ libraries expose their implementations. Providing source is not the same thing as "open source." Microsoft supplies the source to MFC, but it isn't open source. The license makes the difference.