我遇到了一个问题gcc 4.9.2(使用-std = c ++ 11)没有编译一段代码,错误信息是
调用重载的'InsertDataIntoInputMap(int&,boost :: shared_ptr&)'是不明确的
该代码使用msvc 2013进行编译
#include <iostream>
#include <map>
#include <boost/shared_ptr.hpp>
struct Proxy
{
typedef std::map<int, int> InputDataMap;
int a;
};
template<class C, class D>
void InsertDataIntoInputMap(
const typename C::InputDataMap::key_type& key,
const D val)
{
std::cout << "Not shared\n";
}
template<class C, class D>
void InsertDataIntoInputMap(
const typename C::InputDataMap::key_type& key,
const boost::shared_ptr<D> val)
{
if (val)
{
std::cout << "Shared\n";
}
}
int main() {
int a;
boost::shared_ptr<double> x(new double(4.5));
InsertDataIntoInputMap<Proxy>(a, x); …Run Code Online (Sandbox Code Playgroud) 我在xdist上使用py.test(版本2.4,在Windows 7上)为C++库运行许多数值回归和接口测试,C++库通过C模块提供Python接口.
随着时间的推移,测试的数量已增加到2,000个,但我们现在遇到了一些内存问题.无论是否使用xdist,运行测试的python进程的内存使用量似乎都在增加.
在单进程模式中,我们甚至看到了一些错误分配错误的问题,而使用xdist总内存使用可能会降低操作系统(8个进程,每个进程使用> 1GB).
这是预期的行为吗?或者在使用py.test进行大量测试时,是否有其他人遇到过同样的问题?我可以在tearDown(Class)中做些什么来减少内存使用量吗?
目前我无法排除问题存在于C/C++代码内部的可能性,但是当通过py.test之外的Python接口运行一些长期运行的程序时,我确实看到了相对恒定的内存使用情况. .当使用nose代替py.test时我也没有看到任何过多的内存使用(我们使用py.test,因为我们需要junit-xml报告来处理多个进程)
我正在尝试将一个projet从VS2008转换为2010但由于添加了移动构造函数(并且可能存在嵌套的list_of这里的事实)而遇到问题.以下代码片段显示错误(在实际代码中,这些构造用于初始化一些静态):
enum some_enum {R, G, B};
typedef std::pair<some_enum, some_enum> Enum_Pair;
typedef std::vector<some_enum> Enum_list;
typedef std::pair<Enum_Pair, Enum_list> Some_Struct;
typedef std::list<Some_Struct> Full_Struct;
#define MAKEFULLSTRUCT(First_, Second_, some_enums)\
(Some_Struct(Enum_Pair(First_, Second_), list_of (some_enums) ))
int main()
{
int i = G;
Full_Struct test_struct = list_of
MAKEFULLSTRUCT(R, R, R).to_container(test_struct);
}
Run Code Online (Sandbox Code Playgroud)
这导致
error C2668: 'std::vector<_Ty>::vector' : ambiguous call to overloaded function
with [_Ty=some_enum]
vector(593): could be 'std::vector<_Ty>::vector(std::vector<_Ty> &&)'
with [ _Ty=some_enum]
vector(515): or 'std::vector<_Ty>::vector(unsigned int)'
with [ _Ty=some_enum]
while trying to match the argument list '(boost::assign_detail::generic_list<T>)'
with …Run Code Online (Sandbox Code Playgroud)