BOOST_STRONG_TYPEDEF,新表达式,模糊的默认类型转换

时间:2014-05-12 01:34:35

标签: c++ gcc boost

我认为这应该有效:

#include "boost/serialization/strong_typedef.hpp"

BOOST_STRONG_TYPEDEF(int, StrongInt);

int main()
{
    StrongInt len (100);
    int *heapInts = new int [len];
}

gcc 4.8.2:     ./StrongTypeTest.cpp:在函数'int main()'中:     ./StrongTypeTest.cpp:8:30:错误:来自'StrongInt'的模糊默认类型转换

int *heapInts = new int [len];
                         ^

./ StrongTypeTest.cpp:8:30:错误:候选转换包括'StrongInt :: operator const int&()const'和'StrongInt :: operator int&()'

0 个答案:

没有答案