if-else depends on whether T is a complete type

Viewed 502

How to check whether a certain type is a complete type in a certain .cpp?

template<class T>class Test{
    //some fields
    void(*functor)(T*) =[](T*){}; 
    //^ will be written by some .cpp that can access T as complete-type 
    T* t=nullptr;
    void fComplete(){    
        delete t;     //faster
        /** ^ some code that use complete type*/    
    }
    void fForward(){
        functor(t);   //slower
        /** ^ some code that forward declaration is enough*/   
    }
    void f(){  
        /*if(T is complete type){    
            fComplete();
        }else fForward();*/
    }
};

demo

It will be useful when I want to prematurely optimize a delete function in my custom smart pointer.

Can anyone confirm that it is impossible?
I am not asking for a workaround (but I don't mind) - this question is just my curiosity.

2 Answers
Related