我认为这应该有效:
#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&()'