an-tao/trantor

使用下面的代码,可以把编译器降低到c++11

Closed this issue · 4 comments

//from https://github.com/zhaoyaogit/rpclib
#ifndef MAKE_UNIQUE_HPP
#define MAKE_UNIQUE_HPP

#include

namespace std {
// Default behaviour is to assume C++11, overriding RPCLIB_CXX_STANDARD can use
// newer standards:
#if RPCLIB_CXX_STANDARD >= 14

using std::make_unique;

#else

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

#endif

}

#endif /* end of include guard: MAKE_UNIQUE_HPP */

可能还不行,工程里还用了其它c++14以后的特性,比如lambda捕获列表里的move

可是经过我编译测试:(可能g++4.8.5已经支持其他特性)
Redhat 7.2.1511 gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
在以上环境下所需要std::make_unique的头文件:TcpConnectionImpl.h增加头文件引用#include "unique.h"
编译通过。正常生成静态库.a文件。

对了:BufferNode() =default ;改为BufferNode();
就改了这两处,编译过去的。

哦哦,trantor会好些,我以为drogon呢