我有一些(比如动态生成的)代码和 STL 容器,其中包含从该代码访问的 POD 数据(比如std::vector< T >
of )。static_assert(std::is_floating_point< T >::value, "!");
显然我需要用volatile
限定符声明数据。但在这种情况下,gcc会发出错误:
c:\mingw\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++\ext\new_allocator.h:110: ошибка: invalid conversion from 'volatile void*' to 'void*' [-fpermissive]
{ ::operator delete(__p); }
c:\mingw\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++\bits\stl_construct.h:75: ошибка: invalid static_cast from type 'volatile double*' to type 'void*'
{ ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
c:\mingw\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++\bits\stl_algobase.h:372: error: invalid conversion from 'volatile void*' to 'void*' [-fpermissive]
__builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
^
c:\mingw\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++\bits\stl_algobase.h:372: error: invalid conversion from 'const volatile void*' to 'const void*' [-fpermissive]
这是唯一的解决方案,我应该为我自己的分配器提供正确的指针转换更正吗?