Quick Q: static constexpr variable vs. constexpr function? -- StackOverflow

With a nice Quick A by Morwenn that not only gives the right answer as of today, but is current with a feature voted into C++14 just two weeks ago that lets you drop the ()'s:

static constexpr variable vs. function

Is there a difference between declaring floating point constant as a static constexpr variable and a function as in example below, or is it just a matter of style?

class MY_PI
{
public:
    static constexpr float MY_PI_VAR = 3.14f;
    static constexpr float MY_PI_FUN() { return 3.14f; }
}

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.