最新的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中的残缺使用的更多相关文章

  1. 深入研究Visual studio 2017 RC新特性

    在[Xamarin+Prism开发详解三:Visual studio 2017 RC初体验]中分享了Visual studio 2017RC的大致情况,同时也发现大家对新的Visual Studio很 ...

  2. Visual Studio 2017 RC 初探安装

    上次看到博客介绍 Visual Studio 2017 RC,看到其中一个改进是启动很快,这是一大进步,也是低配电脑的程序员的期望.不过还没体验,是驴是骡子拉出来看看,这不就开始下载. 1.打开官网: ...

  3. Visual Studio 2017 RC使用初体验

    .NET Core新式,高效,特别适合用于大规模的Web应用:而传统的.NET Framework则非常适合用于开发Windows桌面应用程序. 一 安装 请下载Visual Studio 2017 ...

  4. 如何创建 Visual Studio 2017 RC 离线安装包

    创建 Visual Studio 的离线安装计划 首先下载相应版本的可执行文件,例如:vs_community.exe.vs_enterprise.exe 或 vs_professional 在 cm ...

  5. Xamarin+Prism开发详解三:Visual studio 2017 RC初体验

    Visual studio 2017 RC出来一段时间了,最近有时间就想安装试试,随带分享一下安装使用体验. 1,卸载visual studio 2015 虽然可以同时安装visual studio ...

  6. Create an offline installation of Visual Studio 2017 RC

    Create an offline installation of Visual Studio 2017 RC ‎2016‎年‎12‎月‎7‎日                             ...

  7. Visual Studio 2015 RC中的ASP.NET新特性和问题修正

    (此文章同时发表在本人微信公众号"dotNET每日精华文章") 微软在Build大会上发布了Visual Studio 2015 RC,这也预示着Visual Studio 201 ...

  8. 在【Xamarin+Prism开发详解三:Visual studio 2017 RC初体验】中分享了Visual studio 2017RC的大致情况,同时也发现大家对新的Visual Studio很是感兴趣。于是发时间深入研究了一下Visual Studio 2017RC 是不是和微软Connect()://2016上说得一样神。

    总共列出了12点,耐心点慢慢看! 1,添加了不少[代码样式]的设置项目. 通过合理的设置每个人都能写出优美的代码,而且团队项目也可以达到统一代码风格. this首选项:可以设置[字段,属性,方法,事件 ...

  9. 关于在最新的 Visual Studio 2017 版本中使用 Web Deploy 遇到的 SSL 连接错误

    错误信息: 无法完成向远程代理 URL 发送请求.请求被中止: 未能创建 SSL/TLS 安全通道. 原因分析: 最新版本的 Visual Studio 中,已经抛弃了 https 协议中旧版 SSL ...

随机推荐

  1. Extjs4中的常用组件:Grid、Tree和Form

    至此我们已经学习了Data包和布局等API.下面我们来学习作为Extjs框架中我们用得最多的用来展现数据的Grid.Tree和Form吧! 目录: 5.1. Grid panel 5.1.1. Col ...

  2. js Date 日期格式化(转)

    var myDate = new Date();myDate.getYear();        //获取当前年份(2位)myDate.getFullYear();    //获取完整的年份(4位,1 ...

  3. memcached命令和配置

    转自:http://www.tuicool.com/articles/VJzAvuB 安装配置 首先,编译.安装.配置libevent库,执行如下命令: wget https://github.com ...

  4. (简单) HDU 1698 Just a Hook , 线段树+区间更新。

    Description: In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of ...

  5. c++读取REG_MULTI_SZ类型注册表

    First: run RegQueryValueEx to get type and necessary memory size: Single byte code: DWORD type, size ...

  6. 【ural1297】 Palindrome

    http://acm.timus.ru/problem.aspx?space=1&num=1297 (题目链接) 题意 求最长回文子串 Solution 后缀数组论文题 穷举每一位,然后计算以 ...

  7. js实现从字符串中查找出现次数最多的字符的两种解决办法

    方法一:正则表达式匹配 var str = "adadfdfseffserfefsefseeffffftsdg"; ; var result = ""; whi ...

  8. 写一篇 Bootstrap弹窗确认的文章。本周完成

    思路; 点击按钮,显示模态 点击确定,异步提交 根据结果,删除指定的记录

  9. 一种新的隐藏-显示模式诞生——css3的scale(0)到scale(1)

    .dropdown-menu {  background: rgba(255, 255, 255, 0.98) none repeat scroll 0 0;  box-shadow: 0 1px 2 ...

  10. 环信 之 iOS 客户端集成三:基础功能

    SDK中,大部分与网络有关的操作,都有三种方法: 同步方法 通过delegate回调的异步方法.要想能收到回调,必须要注册为:[[EaseMob sharedInstance].chatManager ...