Search code examples
c++templatesvisual-c++template-specializationconditional-breakpoint

breakpoint in template for specific template parameter


What if i want to set breakpoint into constructor with condition if I == 10?

template < typename T, int I >
class C 
{
public:

    C<T, I>() { cout << I << endl; }
};

Solution

  • If conditional break point does not work try

    template < typename T, int I >
    class C 
    {
    public:
    
        C() 
        {
           if(I == 10)
           {
    *         int a= 0; //or try __debugbreak();
           }
           cout << I << endl;
        }
    };
    

    EDIT To break on specific class you may use std::is_same<T, U>::value(or boost analogue) in condition