   Using Templates with functions and namespaces
  I'm sure this problem is about as simple as it comes. I have an old hunk of code that was sloppily coded. Because I have never known how to define a simple function in a namespace as a template rather than as a class I left it as a Class. Which of course means I have to create this class, which holds nothing just to access the functions.Cleaning this up I can't seem to get the header \ inline syntax correctMy attempt looks like this so far:#bit.h (A lot of irrelevant stuff snipped)namespace Bit{template <typename T> void Set(T& a_Memory, const T a_Bit);template <typename T> void Flip(T& a_Memory, const T a_Bit);template <typename T> void Clear(T& a_Memory, const T a_Bit);template <typename T> bool Test(const T a_Memory, const T a_Bit);};#include "Bit.inl"#bit.inltemplate <class T>inline void Bit<T>::Set(T& a_Memory, const T a_Bit){a_Memory |= a_Bit;}NOTE : The .inl file is just included in to the .h so that I can seperate the definition\implmentationI think I'm on the right track in the .h, but the syntax in the .inl file is still based on the old class code. I just can't work out how it should be defined. Oh, and yes I've tried looking though the help files, everything I've found refer's to classes.Is this even possible?   
Quote:Original post by gimptemplate <class T>inline void Bit<T>::Set(T& a_Memory, const T a_Bit){a_Memory |= a_Bit;}Bit is now a namespace, not a class template, so no template parameter lists there. Also, function templates are implicitly inline, so the keyword isn't required (it isn't an error to put it there, just redundant).You could also re-open the namespace and put the definitions there:// Bit.inl:namespace Bit {  template <typename T>  void Set(T& a_Memory, const T a_Bit)  {    a_Memory |= a_Bit;  }  // and others too}Or you could define them right where you declare them; with such simple routines there's not much encapsulationg to be done.   