Consider Using constexpr Static Function Variables for Performance in C++ -- Daniel Lemire

When programming, we often need constant variables that are used within a single function.

Consider Using constexpr Static Function Variables for Performance in C++

by Daniel Lemire

From the article:

When programming, we often need constant variables that are used within a single function. For example, you may want to look up characters from a table. The following function is efficient:

char table(int idx) {
  const char array[] = {'z', 'b', 'k', 'd'};
  return array[idx];
}

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.