Giter VIP home page Giter VIP logo

template-metaprogramming-with-cpp's Introduction

Template Metaprogramming with C++

Learn everything about C++ templates and unlock the power of template metaprogramming

详细的了解C++模板,释放模板元编程的力量

  • 作者:Marius Bancila
  • 译者:陈晓伟
  • 首次发布时间:2022年8月29日(来源)

翻译是译者用自己的**,换一种语言,对原作者想法的重新阐释。鉴于我的学识所限,误解和错译在所难免。如果你能买到本书的原版,且有能力阅读英文,请直接去读原文。因为与之相较,我的译文可能根本不值得一读。

— 云风,程序员修炼之道第2版译者

PDF可在本库的Release页面获取。

本书概述

了解元编程,可以创建在编译时进行计算的数据结构和函数。本书将带您了解如何使用模板避免编写重复的代码,以及其为什么会成为通用库(如标准库或Boost)的关键(通用库可用于很多程序中)。

本书将深入了解模板和元编程的基础知识,再练习编写复杂的模板,并探索高级概念,如模板递归、模板参数推导、转发引用、类型特征和条件编译。这个过程中,将了解如何编写可变参数模板,以及如何使用C++20约束和概念为模板参数进行限制。最后,可以使用C++元编程模板来实现各种元编程模式。

本书的最后,将学习如何在日常编程中编写有效的模板和实现元编程。

关键特性

  • 了解C++20的最新特性,并使用STL编写更好的代码

  • 减少应用程序的开发时间,可以更快的进行部署

  • 使用最新标准中引入的新而精简的STL功能

将会学到

  • 类型模板的语法

  • 特化和实例化如何工作

  • 模板参数推断和转发引用

  • 编写可变参数见模板

  • 熟悉类型特征和条件编译

  • 用约束和概念限制C++20中的模板参数

  • 实现CRTP、Mixins和标签分派等模式

适读人群

这本书是为初学者到中级C++开发人员(想要学习和了解模板元编程的人员),以及高级C++开发人员(希望了解与模板相关的新C++20特性和各种习语和模式)。阅读这本书之前,需要有基本的C++编程经验。

作者简介

Marius Bancila是一名软件工程师,为工业和金融部门开发解决方案方面,拥有近20年的经验。他是《现代C++挑战》的作者和《学习C#编程》的合著者。并且是一名软件架构师,专注于Microsoft技术,主要使用C++和C#开发桌面应用程序。热衷于分享其技术专长,自2006年以来,他一直是微软C++和开发人员眼中的技术MVP。Marius住在罗马尼亚,并且活跃在各种网络社区

本书相关

template-metaprogramming-with-cpp's People

Contributors

xiaoweichen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

template-metaprogramming-with-cpp's Issues

可能存在的问题

hi xiaowei , 首先十分感谢您无私的奉献,为国内C++的开发者提供国外优秀C++书籍的中文翻译
在此提出几个有可能的翻译问题,也是尽一份绵薄之力

******* 1 中文译本的 91 页
《注释中有几个参考点。[1] 声明了一个名为 parser 的类模板,[2] 定义一个名为 handle 的函数,
该函数以 double 作为参数。类模板的定义在 [3]。该类包含一个名为 run 的方法,该方法调用一个
名为 handle 的函数,其参数值为 42,位于 [4]。》

未在程序里发现 名为 run 的方法

******* 2 中文译本的 121 页
《这个实现使用 std::forward 将左值作为左值传递,将右值作为右值传递,同样适用于可变函数
模板。下面是 std::make_unique 函数的概念实现,其创建了一个 std::unique_ptr 对象:》
这段话下面的程序估计是粘贴错误了,粘贴的程序和上面的程序一模一样,对比了原书确认粘贴错了
应该的程序是

template<typename T, typename... Args>
std::unique_ptr make_unique(Args&&... args)
{
return std::unique_ptr(
new T(std::forward(args)...));
}

*******3 中文译本的 144 页
最下面的程序
template <
2 typename T,
3 typename=typenamestd::enable_if_t< // 没有空格
4 std::is_integral_v>>
5 struct integral_wrapper

******* 4 中文译本的 152 页
图标中的 :
《 is_empty C++11
是否为空类型。空类型是一种类类型 (不是联合体),
是否为空类型。空类型是一种类类型 (不是联合体), // 重复了
没有虚函数,没有虚基类,也没有非空基类。 》

******* 5 中文译本的 202 页
图标中的 :
《 注意,基类模板中的成员函数和派生类中调用的成员函数具有不同的名称。否则,若具有相同称,因为它们不再是虚函数了,派生类成员函数将隐藏基类成员,、。》 // 标点符号问题

******* 6
整个翻译里面 很多处 stirng 都是 作为 粗体蓝色表示,显得很突兀

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.