惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
GbyAI
GbyAI
L
LangChain Blog
B
Blog
博客园 - 三生石上(FineUI控件)
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
Recent Announcements
Recent Announcements
P
Proofpoint News Feed
U
Unit 42
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
小众软件
小众软件
I
InfoQ
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
C
Check Point Blog

博客园 - chuncn

Eslint 规则说明 磁盘阵列RAID原理、种类及性能优缺点对比 asp.net中调用命令行 JavaScript中的CSS属性对照表 webRTC-实时流媒体的福音 qt 5.1 quick vs qt 4.x quick for control zeroc ice的概念、组成与服务 国内外期货、外汇、股指期货 交易时间 使用Visual Leak Detector for Visual C++ 捕捉内存泄露 window8 metro 之 RSA sqlite in qt Qt 表格&列表数据驱动化(c++) 原创 Qt读写INI配置文件 Qt多国语言的实现与切换(国际化) Qt编码风格 -- 转 win32里玩事件-转 c++中捕捉内存泄露、异常 win32 http download win32 DirectUI控件开发与调用指南
Windows环境下使用Boost
chuncn · 2012-09-10 · via 博客园 - chuncn

一、 下载boost

1、boostpro

http://www.boostpro.com/download/

2、boost.org(本文下载方式)

http://www.boost.org/users/download/

http://sourceforge.net/projects/boost/files/boost/1.51.0/

boost_1_51_0.zip 下载并解压到C盘根文件夹

二、编译boost

1、生成生命行程序

  执行bootstrap.bat

2、编译

  执行b2.exe,完成后显示:

The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
    C:/boost_1_51_0
The following directory should be added to linker library paths:
    C:\boost_1_51_0\stage\lib

三、使用boost

1、创建一个win32 console

2、引用bootst

  C/C++ -> Additional Include Directories: C:\boost_1_51_0
  Linker-> Additional Library Directories: C:\boost_1_51_0\stage\lib
  Linker->Input->Additional Dependencies :libboost_signals-vc110-mt-gd-1_51.lib;libboost_regex-vc110-mt-gd-1_51.lib;

3、Code如下:

#include "stdafx.h"
#include <boost/regex.hpp>
#include <boost/signals.hpp>
#include <boost/lambda/lambda.hpp> 

#include <iostream> 
#include <cassert> 
 
struct print_sum { 
  void operator()(int x, int y) const { std::cout << x+y << std::endl; } 
}; 
 
struct print_product {
 
  void operator()(int x, int y) const { std::cout << x*y << std::endl; }
 
};

int _tmain(int argc, _TCHAR* argv[])
{
    boost::signal2<void, int, int, boost::last_value<void>, std::string> sig;
    sig.connect(print_sum());
    sig.connect(print_product());
    sig(3, 5);
    std::string line;     
    boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );    
    while (std::cin)
    {         
        std::getline(std::cin, line);         
        boost::smatch matches;        
        if (boost::regex_match(line, matches, pat))  
            std::cout << matches[2] << std::endl;     
    }
	return 0;
}

 示例程序在vs2012下通过,输出:

8
15