std::enable_if to conditionally compile a member function

前端 未结 7 2083
执笔经年
执笔经年 2020-11-22 04:57

I am trying to get a simple example to work to understand how to use std::enable_if. After I read this answer, I thought it shouldn\'t be too hard to come up wi

7条回答
  •  悲&欢浪女
    2020-11-22 05:38

    Here is my minimalist example, using a macro. Use double brackets enable_if((...)) when using more complex expressions.

    template = 0>
    using helper_enable_if = int;
    
    #define enable_if(value) typename = helper_enable_if
    
    struct Test
    {
         template
         void run();
    }
    

提交回复
热议问题