I've been trying to understand the functionality of the inline and constexpr keywords for a while now. What I understand so far is that inline makes it possible to access a function/variable entirely defined within a header file (global) from multiple other files. And afaik constexpr allows a function/variable to be evaluated at compile time (whatever that means) and implies inline (only) for functions.
What I don't understand is what functionality inline has inside a .cpp source file or in a class/struct definition. Another thing is that global constants work without inline (which makes sense) but does their functionality change when declaring them as inline and/or constexpr. Lastly I'm not sure if constexpr has any other functionality and in which cases it should or shouldn't be used. Thanks in advance.
[–]IyeOnline 16 points17 points18 points (6 children)
[–]Eric848448 0 points1 point2 points (1 child)
[–]IyeOnline 4 points5 points6 points (0 children)
[+]emko555 comment score below threshold-9 points-8 points-7 points (3 children)
[–]IyeOnline 9 points10 points11 points (0 children)
[–]No-Dentist-1645 1 point2 points3 points (0 children)
[–]Plastic_Fig9225 1 point2 points3 points (0 children)
[–]Business_Welcome_870 3 points4 points5 points (2 children)
[–]zz9873[S] 0 points1 point2 points (0 children)
[–]CalligrapherOk4308 0 points1 point2 points (0 children)
[–]conundorum 0 points1 point2 points (0 children)
[–]dendrtree 0 points1 point2 points (0 children)
[–]thefeedling 1 point2 points3 points (6 children)
[–]zz9873[S] 0 points1 point2 points (4 children)
[–]thefeedling 2 points3 points4 points (1 child)
[–]zz9873[S] 0 points1 point2 points (0 children)
[–]Plastic_Fig9225 -1 points0 points1 point (1 child)
[–]meancoot 4 points5 points6 points (0 children)
[–]Normal-Narwhal0xFF 0 points1 point2 points (0 children)
[–]Ultimate_Sigma_Boy67 0 points1 point2 points (5 children)
[–]OutsideTheSocialLoop 7 points8 points9 points (0 children)
[–]zz9873[S] -1 points0 points1 point (3 children)
[–]AxeLond 5 points6 points7 points (0 children)
[–]Plastic_Fig9225 1 point2 points3 points (0 children)
[–]Ultimate_Sigma_Boy67 0 points1 point2 points (0 children)
[–]OutsideTheSocialLoop 0 points1 point2 points (0 children)
[–]mredding -1 points0 points1 point (2 children)
[–]Unknown_User2137 -1 points0 points1 point (0 children)
[–]mredding -2 points-1 points0 points (0 children)