Boost 元编程学习笔记.docxVIP

  • 9
  • 0
  • 约2.61千字
  • 约 3页
  • 2021-08-28 发布于山东
  • 举报
第 PAGE \* Arabic 1 页 Boost 元编程学习笔记 (二) C++ 中的模板机制是众所周知的,它的大名不仅仅在这个神奇的机制本身,还在于它总能在不经意间给我们带来意外的惊喜。它也为我们的自然语言元编程提供了丰富的工具。这章我们将去发掘一下C++中自然语言元编程的基础机制和共通的习惯用语。 1.数值计算 下面的代码转换unsigned decimal numerals 到它们的二进制形式: template unsigned long N struct binary { static unsigned const value = binaryN/10::value 1 // prepend higher bits | N%10; // to lowest bit }; template // specialization struct binary0 // terminates recursion { static unsigned const value = 0; }; unsigned con

文档评论(0)

1亿VIP精品文档

相关文档