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

Template Metaprogramming – Difference Between Using Enum Hack and Static Const – w3toppers.com

2023-04-18 06:53| 来源: 网络整理| 查看: 265

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 实验室设备网 版权所有