Conditional Compile using Boost type-traits

后端 未结 3 1875
感情败类
感情败类 2021-02-06 09:49

I have a template that I would like to conditionally compile depending on the type of the argument. I only care about differentiating between \"Plain Old Data\" (POD), i.e., in

3条回答
  •  时光取名叫无心
    2021-02-06 10:10

    Using preprocessor here is not possible. Have a look at Boost Enable If library instead.

    Specifically, in your case it would look like (not tested):

    void bar (typename enable_if , T>::type do_something)
    {
        // if is POD
    }
    
    void bar (typename disable_if , T>::type do_something)
    {
        // if not
    }
    

提交回复
热议问题