NamedType:在C ++中实现强类型

时间:2021-05-22 17:39:07
【文件属性】:
文件名称:NamedType:在C ++中实现强类型
文件大小:116KB
文件格式:ZIP
更新时间:2021-05-22 17:39:07
C++ 强类型是一种类型,用于代替其他类型,以通过其名称来承载特定含义。 该项目使用C ++进行了强类型实验。 所有组件都在命名空间中fluent 。 您可以找到一系列博客文章,其中解释了库的基本原理以及强类型的用法。 基本用法 它的核心部分是模板化类NamedType,该类可用于使用类似typedef的语法声明一个强类型: using Width = NamedType< double>; using Height = NamedType< double>; 可以使界面更具表现力和更健壮。 注意下面的构造函数如何显示期望参数的顺序: class Rectangle { public: Rectangle (Width width, Height height) : width_(width.get(
【文件预览】:
NamedType-master
----CMakeLists.txt(2KB)
----.gitignore(33B)
----README.md(4KB)
----test()
--------main.cpp(117B)
--------CMakeLists.txt(1KB)
--------tests.cpp(31KB)
--------catch.hpp(510KB)
----.clang-format(3KB)
----LICENSE(1KB)
----include()
--------NamedType()
----cmake()
--------NamedTypeConfig.cmake.in(222B)
----.travis.yml(2KB)

网友评论