adapting a non-constexpr integral value to a non-type template parameter, and code bloat

前端 未结 4 1417
梦毁少年i
梦毁少年i 2021-01-13 03:03

Consider a function object F taking a constexpr size_t argument I

struct F
{
    template 
    constex         


        
4条回答
  •  借酒劲吻你
    2021-01-13 03:17

    I'll take the obvious position here and ask if "I want to emphasize that it is constexpr by using it as a template argument" is worth this cost and if:

    struct F
    {
        constexpr size_t operator()(size_t i) const { return i; }
        template 
        constexpr size_t operator()(size ) const { return (*this)(I); }
    };
    

    would not be a much simpler solution.

提交回复
热议问题