Menu

Return type std::enable_if_t

2022-06-27
2022-07-05
  • Gaetano Mendola

    Gaetano Mendola - 2022-06-27

    cppcheck (2.8) is not able to understand that a return type declared as:

    std::enable_if_t<sizeof(uint64_t_==8> is void.</sizeof(uint64_t_==8>

    Example:

    #include <type_traits>
    #include <stdint.h>
    
    std::enable_if_t<sizeof(uint64_t)==8>
    foo() {
    }
    
    int main() {
      foo();
    }
    

    cppcheck reports: Found a exit path from function with non-void return type that has missing return statement

    note that if the return type is declared as:

    std::enable_if<sizeof(uint64_t)==8>::type then cppcheck recognize the return type as void.</sizeof(uint64_t)==8>

     

    Last edit: Gaetano Mendola 2022-06-27
  • Daniel Marjamäki

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.