Template Metaprogramming – Difference Between Using Enum Hack and Static Const – w3toppers.com | 您所在的位置:网站首页 › 戴尔笔记本bios更新一直重启 › Template Metaprogramming – Difference Between Using Enum Hack and Static Const – w3toppers.com |
Enums aren’t lvals, static member values are and if passed by reference the template will be instanciated: void f(const int&); f(TMPFib::value);If you want to do pure compile time calculations etc. this is an undesired side-effect. The main historic difference is that enums also work for compilers where in-class-initialization of member values is not supported, this should be fixed in most compilers now. There may also be differences in compilation speed between enum and static consts. There are some details in the boost coding guidelines and an older thread in the boost archives regarding the subject. |
CopyRight 2018-2019 实验室设备网 版权所有 |