Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 853 Bytes

c26497.md

File metadata and controls

34 lines (26 loc) · 853 Bytes
title ms.date f1_keywords helpviewer_keywords description
Warning C26497
03/22/2018
C26497
USE_CONSTEXPR_FOR_FUNCTION
C26497
CppCoreCheck rule that enforces C++ Core Guidelines F.4

Warning C26497

This function function-name could be marked constexpr if compile-time evaluation is desired (f.4).

See also

C++ Core Guidelines F.4.

Example

const int GetTheAnswer(int x) noexcept { return 42 + x; } // Could be marked constexpr

void function1() noexcept
{
    const int theAnswer = GetTheAnswer(0);
}

To reduce code analysis noise on new code, this warning isn't issued if the function has an empty implementation.

int function1(){  // no C26497
    return 1;
}
void function2(){} // no C26497