Tech Off Post

Single Post Permalink

View Thread: C++0x (vs2010) question, please tell me what i'm doing wrong
  • User profile image
    Dexter

    In this particular case it seems to me that the simplest solution is to get rid of the Function template argument:

    template<typename T> 
    class test_c {
    public:    
        explicit test_c(T p, std::function<void(T)> func) 
            : m_p(p), m_Func(func) {
        }     
        
        ~test_c(void) {        
            m_Func(m_p);
        }
        
        T get(void) const {        
            return m_p;
        }
    
    private:    
        T m_p;
        const std::function<void(T)> m_Func;
    };