vendredi 27 juillet 2018

Template method not called appropriately

I have below code:

PtrT callMe()
{
    auto ptr =  mytemplate <const int, int>
        (std::move(u_ptr), a, b, c, d);
    std::cout << "Test\n";
    return ptr;
}

int main()
{
PtrT p;
p = callMe();
}

The above is the sample code - the original code compiles fine. The issue is that if I do not have the "std::cout << "Test\n" C++ statement mytemplate execution does not occur.

The only thing that I understand that "std::cout << "Test\n" (mytemplate code gets called) is to add a delay - but the template construction happens at compile time?

Why my template is not called properly without the extra "std::cout << "Test\n" statement?

Aucun commentaire:

Enregistrer un commentaire