C++ binary constant/literal

后端 未结 7 2141
-上瘾入骨i
-上瘾入骨i 2020-12-14 21:09

I\'m using a well known template to allow binary constants

template< unsigned long long N >
struct binary
{
  enum { value = (N % 10) + 2 * binary<          


        
7条回答
  •  失恋的感觉
    2020-12-14 21:46

    C++0x has user-defined literals, which could be used to implement what you're talking about.

    Otherwise, I don't know how to improve this template.

提交回复
热议问题