Separating template implementation from declaration

I am separating the template implementation from the declaration in the way described below.

When coding the implementation, is it a good idea to have the two code sections

#ifndef TESTTEMP_IPP
#define TESTTEMP_IPP

and

#include "TestTemp.hpp"

Files are as follows

// TestTemp.hpp

#ifndef TESTTEMP_HPP
#define_TESTTEMP_HPP

template<class T>
class TestTemp
{

public:

   TestTemp();
   void SetValue( T obj_i );
    T Getalue();

private:

   T m_Obj;

};

#include "TestTemp.ipp"

#endif
// TestTemp.ipp

#ifndef TESTTEMP_IPP
#define TESTTEMP_IPP

#include "TestTemp.hpp"
  
template <class T>
TestTemp<T>::TestTemp()
{}

template <class T>
void TestTemp<T>::SetValue( T obj_i )
{} 

template <class T>
T TestTemp<T>::Getalue()
{
return m_Obj;
}

#endif

include infinite loop?

Meaning I remove

#include "TestTemp.hpp"

from the .ipp.

Correct?

Well, one has to go! :smiley: In the C++ Boost libraries, why is there a ".ipp" extension on some header files - Stack Overflow

My plan is to have

#include "TestTemp.ipp"

in the the .hpp

So I will remove the include from the ipp.

---------- Post updated at 03:28 PM ---------- Previous update was at 03:25 PM ----------

Yes, my plan was to have things similar to what is done in boost.

Good luck! Templates are cool! I use RogueWave here, a bit richer than STL.

There is another question. I have a class called Layer separated in 3 files

layer.hpp declaration
layer.ipp template implementations and inline functions
layer.cpp all remaining implementations

My question is what include files need I put in ipp and cpp.
Currently this is what I have.

// layer.hpp

#ifndef LAYER_HPP
#define LAYER_HPP

#include <assert.h>
#include <stdarg.h>

#include "tomso/optparse/parsing.hpp"
#include "tomso/string/string.hpp"
#include "tomso/linear_algebra/vect2.hpp"
#include "tomso/linear_algebra/gauss_elim.hpp"
#include "tomso/raytrace/layint_linear.hpp"
#include "tomso/raytrace/layint_spline.hpp"
#include "tomso/raytrace/layint_trigon.hpp"

enum TWave {
  PWave,
  SWave
};

class Layer {

  protected:

    Vect2  Xi;        // Top left corner of sound speed model
    Vect2  Xf;        // Bottom right corner of sound speed model
    float  VSVP;    
    bool  PS;
    ...

// layer.ipp

#include <assert.h>
#include <stdarg.h>

#include "tomso/optparse/parsing.hpp"
#include "tomso/string/string.hpp"
#include "tomso/linear_algebra/vect2.hpp"
#include "tomso/linear_algebra/gauss_elim.hpp"
#include "tomso/raytrace/layint_linear.hpp"
#include "tomso/raytrace/layint_spline.hpp"
#include "tomso/raytrace/laymod_trigon.hpp"

inline Layer::Layer (
  const Vect2&  xi,
  const Vect2&  xf
) {

  Xi = xi;
  Xf = xf;
  VSVP = DefVSVP;
  PS = false;
  Int = NULL;

}
// layer.cpp

#include "tomso/raytrace/layer.hpp"

Layer::~Layer (
) {

  if (Int != NULL) {
    delete Int;
  }
  if (ModP != NULL) {
    delete ModP;
  }
  if (ModS != NULL) {
    delete ModS;
  }

}

Cpp and instantiators include hpp, and hpp includes ipp.