[英]error C2660: 'std::allocator<char>::allocate': function does not take 2 arguments
Code:代码:
#include <string>
#include <boost/format.hpp>
int main() {
boost::format fmt;
auto str = fmt % L"";
}
Errors:错误:
1>D:.conan\a9fe50\1\include\boost\format\alt_sstream_impl.hpp(261,1): error C2660: 'std::allocator::allocate': function does not take 2 arguments 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xmemory(838,65): message: see declaration of 'std::allocator::allocate' 1>D:.conan\a9fe50\1\include\boost\format\alt_sstream_impl.hpp(228): message: while compiling class template member function 'int boost::io::basic_altstringbuf<Ch,Tr,Alloc>::overflow(int)' 1>
1>D:.conan\a9fe50\1\include\boost\format\alt_sstream_impl.hpp(261,1): 错误 C2660: 'std::allocator::allocate': function 不占用 2 ZDBC11CAA5BDA99F77E6FB4DABD882ED7 Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xmemory(838,65):消息:请参阅 'std::allocator::allocate' 1>D 的声明:.conan\a9fe50\1\include\boost\format\alt_sstream_impl.hpp(228): message: while compiling class template member function 'int boost::io::basic_altstringbuf<Ch,Tr,Alloc>::overflow(int )' 1>
with 1> [ 1> Ch=char, 1>与 1> [ 1> Ch=char, 1>
Tr=std::char_traits, 1> Alloc=std::allocator 1> ] 1>D:.conan\a9fe50\1\include\boost\format\format_class.hpp(173): message: see reference to class template instantiation 'boost::io::basic_altstringbuf<Ch,Tr,Alloc>' being compiled 1>Tr=std::char_traits, 1> Alloc=std::allocator 1> ] 1>D:.conan\a9fe50\1\include\boost\format\format_class.hpp(173):消息:见参考 class 模板实例化'boost::io::basic_altstringbuf<Ch,Tr,Alloc>' 正在编译 1>
with 1> [ 1> Ch=char, 1>与 1> [ 1> Ch=char, 1>
Tr=std::char_traits, 1> Alloc=std::allocator 1> ] 1>D:\Documents\source\repos\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp(6): message: see reference to class template instantiation 'boost::basic_format<char,std::char_traits,std::allocator>' being compiled 1>Generating Code... 1>Done building project "ConsoleApplication3.vcxproj" -- FAILED.Tr=std::char_traits, 1> Alloc=std::allocator 1> ] 1>D:\Documents\source\repos\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp(6):消息:见参考 class 模板实例化'boost ::basic_format<char,std::char_traits,std::allocator>' 正在编译 1>Generating Code... 1>Done building project "ConsoleApplication3.vcxproj" -- 失败。
I upgraded VC++ today from 16.9 to 16.10, then compilation was broken.我今天将 VC++ 从 16.9 升级到 16.10,然后编译失败。 It only happens when I use
std:c++latest
, but works fine with 'std:c++17'.它仅在我使用
std:c++latest
时发生,但适用于“std:c++17”。
The library lacks c++20 support (see https://en.cppreference.com/w/cpp/memory/allocator/allocate )该库缺少 c++20 支持(请参阅https://en.cppreference.com/w/cpp/memory/allocator/allocate )
You can, for now, opt for c++17 compilation.现在,您可以选择 c++17 编译。 Also, see whether they know about this issue, and if not report it to the developers.
另外,看看他们是否知道这个问题,如果不知道,请向开发人员报告。
wformat
wformat
I realize this is a few months old now, but I just hit this same issue with boost 1.70 after upgrading VS 2019. All I did was remove the 2nd argument to the 'allocate' call on line 261 of alt_sstream_impl.hpp, since it's just a hint/optimization that was deprecated in c++ 17, and now gone in c++ 20. Fortunately, it's an inline method, so no linker issues.我意识到这已经几个月了,但是在升级 VS 2019 之后,我刚刚在 boost 1.70 中遇到了同样的问题。我所做的只是删除了 alt_sstream_impl.hpp 的第 261 行的“分配”调用的第二个参数,因为它只是在 c++ 17 中已弃用的提示/优化,现在在 c++ 20 中消失。幸运的是,它是一种内联方法,因此没有 linker 问题。
You can define _HAS_DEPRECATED_ALLOCATOR_MEMBERS您可以定义 _HAS_DEPRECATED_ALLOCATOR_MEMBERS
It will reenable the removed "allocator stuff" in C++20 even when you compile with C++20 standard selected.即使您使用选择的 C++20 标准进行编译,它也会重新启用 C++20 中已删除的“分配器内容”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.