Boost.Hana在visual studio 2017 rc中的残缺使用
最新的visual studio还不支持hana,不知道vs2017正式版本出后会不会支持。等不及了,先用rc版试试吧。
1、从https://github.com/boostorg/hana下载或拉取最新版本,我们只需要'include/boost/'目录中的所有文件。

2、新建一个控制台应用程序:

3、将hana文件复制到目录下(或者不复制,而是直接添加文件包含目录),进行一些简单配置,然后在cpp文件中随便写一点关联hana的代码:



4、编译。当然通不过!把错误概括一下,我用了一个比较山寨的办法,顺便也传到了https://github.com/freezestudio/hana.zh/blob/master/ReadMe.txt里。
vs2017 解析 delctype(...)::value 时会出错,只好将此语句分解成2步:
1、 using xxx = decltype(...);
2、 xxx::value; 修改处请参见: error C2039 hana/detail/index_if.hpp : value 不是 global namespace 的成员
error C2146 hana/detail/unpack_flatten.hpp : 语法错误 缺少 > (在标识符value的前面)
error C2146 hana/detail/hash_table.hpp : 语法错误 缺少 ; (在标识符type的前面)



5、如果还是不能通过编译,那就根据上面的山寨方法接着改吧,基本上就是这3个文件编译时有问题,也可以对照https://github.com/freezestudio/hana.zh的hana头文件修改。经过这个山寨修改,终于通过编译了。我们开始跑demo吧:在hana目录中'example/tutorial/quickstart.cpp',同样问题连连,还是先‘魔改':
#include "stdafx.h" #include "hana.hpp"
#include <cassert>
#include <iostream>
#include <string> namespace hana = boost::hana;
struct Fish { std::string name; };
struct Cat { std::string name; };
struct Dog { std::string name; }; int main()
{ auto animals = hana::make_tuple(Fish{ "Nemo" }, Cat{ "Garfield" }, Dog{ "Snoopy" }); using namespace hana::literals; // Access tuple elements with operator[] instead of std::get.
Cat garfield = animals[1_c]; // Perform high level algorithms on tuples (this is like std::transform)
auto names = hana::transform(animals, [](auto a) { return a.name; }); auto reverse_names = hana::reverse(names);
auto reverse_names2 = hana::make_tuple("Snoopy", "Garfield", "Nemo"); //assert(hana::reverse(names) == hana::make_tuple("Snoopy", "Garfield", "Nemo")); auto animal_types = hana::make_tuple(hana::type_c<Fish*>, hana::type_c<Cat&>, hana::type_c<Dog>); auto no_pointers = hana::remove_if(animal_types, [](auto a) {
return hana::traits::is_pointer(a);
}); //static_assert(no_pointers == hana::make_tuple(hana::type_c<Cat&>, hana::type_c<Dog>), ""); auto has_name = hana::is_valid([](auto&& x) -> decltype((void)x.name) {}); static_assert(has_name(garfield));
static_assert(!has_name()); return ;
}
看到了吧,static_assert都注释掉了。因为vc编译器通不过!
好了,这就是残缺版的hana。
Boost.Hana在visual studio 2017 rc中的残缺使用的更多相关文章
- 深入研究Visual studio 2017 RC新特性
在[Xamarin+Prism开发详解三:Visual studio 2017 RC初体验]中分享了Visual studio 2017RC的大致情况,同时也发现大家对新的Visual Studio很 ...
- Visual Studio 2017 RC 初探安装
上次看到博客介绍 Visual Studio 2017 RC,看到其中一个改进是启动很快,这是一大进步,也是低配电脑的程序员的期望.不过还没体验,是驴是骡子拉出来看看,这不就开始下载. 1.打开官网: ...
- Visual Studio 2017 RC使用初体验
.NET Core新式,高效,特别适合用于大规模的Web应用:而传统的.NET Framework则非常适合用于开发Windows桌面应用程序. 一 安装 请下载Visual Studio 2017 ...
- 如何创建 Visual Studio 2017 RC 离线安装包
创建 Visual Studio 的离线安装计划 首先下载相应版本的可执行文件,例如:vs_community.exe.vs_enterprise.exe 或 vs_professional 在 cm ...
- Xamarin+Prism开发详解三:Visual studio 2017 RC初体验
Visual studio 2017 RC出来一段时间了,最近有时间就想安装试试,随带分享一下安装使用体验. 1,卸载visual studio 2015 虽然可以同时安装visual studio ...
- Create an offline installation of Visual Studio 2017 RC
Create an offline installation of Visual Studio 2017 RC 2016年12月7日 ...
- Visual Studio 2015 RC中的ASP.NET新特性和问题修正
(此文章同时发表在本人微信公众号"dotNET每日精华文章") 微软在Build大会上发布了Visual Studio 2015 RC,这也预示着Visual Studio 201 ...
- 在【Xamarin+Prism开发详解三:Visual studio 2017 RC初体验】中分享了Visual studio 2017RC的大致情况,同时也发现大家对新的Visual Studio很是感兴趣。于是发时间深入研究了一下Visual Studio 2017RC 是不是和微软Connect()://2016上说得一样神。
总共列出了12点,耐心点慢慢看! 1,添加了不少[代码样式]的设置项目. 通过合理的设置每个人都能写出优美的代码,而且团队项目也可以达到统一代码风格. this首选项:可以设置[字段,属性,方法,事件 ...
- 关于在最新的 Visual Studio 2017 版本中使用 Web Deploy 遇到的 SSL 连接错误
错误信息: 无法完成向远程代理 URL 发送请求.请求被中止: 未能创建 SSL/TLS 安全通道. 原因分析: 最新版本的 Visual Studio 中,已经抛弃了 https 协议中旧版 SSL ...
随机推荐
- iOS所有常用证书,appID,Provisioning Profiles配置说明及制作图文教程
概述: 苹果的证书繁锁复杂,制作管理相当麻烦,今天决定重置一个游戏项目中的所有证书,做了这么多次还是感觉很纠结,索性直接记录下来,日后你我他查阅都方便: 首先得描述一下各个证书的定位,作用,这样在制作 ...
- java web基础 --- URL重定向Filter
java web基础 --- URL重定向Filter httpRequest.getRequestDispatcher("/helloWorld").forward(httpRe ...
- FIFO存储器
FIFO( First In First Out)简单说就是指先进先出.由于微电子技术的飞速发展,新一代FIFO芯片容量越来越大,体积越来越小,价格越来越便宜.作为一种新型大规模集成电路,FIFO芯片 ...
- 算法系列001---dfs|多叉|解空间树理解
1.研究范围 1)多叉树,图的遍历 2)回溯法的解空间树=多叉树的遍历 2.研究方法 我们现在研究的是多叉树的遍历,突然想到为什么不能直接用二叉树的遍历方法呢?我们抱着这个问题,先找到多叉树的结构不同 ...
- mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'
就当作自己忘记Mysql密码把,忘记密码的解决方法 一.mysql登录错误mysqladmin: connect to server at 'localhost' failederror: 'Acce ...
- jenkins 构建时,取消构建测试类
如图 点击配置,添加clean install -Dmaven.test.skip=true 保存即可
- C++中类的大小计算方法总结《网络+总结》
C++中类的成员函数,静态成员是不占类的大小的.类的大小等于基类的大小+子类个non-static成员变量的大小再+非虚基类大小,如果有多态性还要考虑vptr(可能不止一个)大小,这里成员变量是会被字 ...
- [Angular Tutorial] 14 -Animations
在这一步中,我们将会通过在我们先前创建的模板代码中添加CSS和JavaScript动画效果来扩展我们的web应用. ·我们现在使用ngAnimate模块来允许动画效果贯穿整个应用. ·我们也依赖于自带 ...
- poj 3641 ——2016——3——15
传送门:http://poj.org/problem?id=3461 题目大意:给你两个字符串p和s,求出p在s中出现的次数. 题解:这一眼看过去就知道是KMP,作为模板来写是最好不过了.... 这道 ...
- 微信网页授权redirect_uri错误的可能错误之一
授权回调页面域名 后面不要加/ 加了/ 就会出错.