PIMPL and implementation file

I'm trying to learn the PIMPL idiom. I got the basic idea but I have trouble figuring out how to set-up all the templates as I both the general class and the private one are templates. The compiler tells me that "'NodePimp' : is not a member of 'global namespace'", so I believe it's something about how I initialize NodePimp as a member type of Node. Also, can I do somehow to write the template list only once instead of writing a separate template list for each nested class, as it is practically the same? Thanks in advance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include"Node.h"
#include<Memory>

template<class data_type, typename key_type, size_t cost_type>
 template<class data_type, typename key_type, size_t cost_type>
   class Node<data_type,key_type,cost_type>::NodePimp
{
    public:
		NodePimp(const data_type & value, const key_type & key, 
                              const cost_type & cost);
	       ~NodePimp();
//other methods

    private:
		std::unique_ptr<data_type>  value_;
		std::unique_ptr<key_type >   key_  ;
		std::unique_ptr<cost_type>   cost_ ;
};

 template<class data_type, typename key_type, size_t cost_type>
 template<class data_type, typename key_type, size_t cost_type>
 Node<data_type, key_type, size_t>::NodePimp<data_type, key_type, cost_type>::
 NodePimp(const data_type & value, const key_type & key,const cost_type & cost) :
  value_(new data_type(value)), key_(new key_type(key)),       
  cost_(new cost_type(cost))
{
  
};

//..... 
Last edited on
No one? =\
Topic archived. No new replies allowed.