error C2660: 'std::allocator<char>::allocate': 函数不接受 2 个参数
error C2660: 'std::allocator<char>::allocate': function does not take 2 arguments
代码:
#include <string>
#include <boost/format.hpp>
int main() {
boost::format fmt;
auto str = fmt % L"";
}
错误:
1>D:.conan\a9fe50\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
Studio19\Community\VC\Tools\MSVC.29.30037\include\xmemory(838,65):
message : see declaration of 'std::allocator::allocate'
1>D:.conan\a9fe50\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>
Tr=std::char_traits, 1> Alloc=std::allocator 1>
] 1>D:.conan\a9fe50\include\boost\format\format_class.hpp(173):
message : see reference to class template instantiation
'boost::io::basic_altstringbuf<Ch,Tr,Alloc>' being compiled 1>
with 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.
环境
- OS: Win10-64位
- VC++ 2019 16.10.0
- 配置:x86
- SDK版本:10.0(最新安装版本)
- 语言:std:c++最新
- 提升:1.73
我今天将 VC++ 从 16.9 升级到 16.10,然后编译就坏了。
它仅在我使用 std:c++latest
时发生,但在 'std:c++17'.
中工作正常
库缺少 c++20 支持(参见 https://en.cppreference.com/w/cpp/memory/allocator/allocate)
您现在可以选择 c++17 编译。另外,看看他们是否知道这个问题,如果不知道就报告给开发者。
旁注
- 我认为样本减少了,但在我看来文字应该变窄,或者 fmt 应该是
wformat
- Boost 1.76 似乎没有这个问题,请尝试升级 boost
我意识到这已经有几个月了,但我在升级 VS 2019 后用 boost 1.70 遇到了同样的问题。我所做的只是删除了第 261 行 'allocate' 调用的第二个参数alt_sstream_impl.hpp,因为它只是一个 hint/optimization,在 c++ 17 中被弃用,现在在 c++ 20 中消失了。幸运的是,它是一个内联方法,所以没有链接器问题。
您可以定义_HAS_DEPRECATED_ALLOCATOR_MEMBERS
即使您选择了 C++20 标准进行编译,它也会重新启用 C++20 中已删除的“分配器内容”。
代码:
#include <string>
#include <boost/format.hpp>
int main() {
boost::format fmt;
auto str = fmt % L"";
}
错误:
1>D:.conan\a9fe50\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 Studio19\Community\VC\Tools\MSVC.29.30037\include\xmemory(838,65): message : see declaration of 'std::allocator::allocate' 1>D:.conan\a9fe50\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>
Tr=std::char_traits, 1> Alloc=std::allocator 1> ] 1>D:.conan\a9fe50\include\boost\format\format_class.hpp(173): message : see reference to class template instantiation 'boost::io::basic_altstringbuf<Ch,Tr,Alloc>' being compiled 1>
with 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.
环境
- OS: Win10-64位
- VC++ 2019 16.10.0
- 配置:x86
- SDK版本:10.0(最新安装版本)
- 语言:std:c++最新
- 提升:1.73
我今天将 VC++ 从 16.9 升级到 16.10,然后编译就坏了。
它仅在我使用 std:c++latest
时发生,但在 'std:c++17'.
库缺少 c++20 支持(参见 https://en.cppreference.com/w/cpp/memory/allocator/allocate)
您现在可以选择 c++17 编译。另外,看看他们是否知道这个问题,如果不知道就报告给开发者。
旁注
- 我认为样本减少了,但在我看来文字应该变窄,或者 fmt 应该是
wformat
- Boost 1.76 似乎没有这个问题,请尝试升级 boost
我意识到这已经有几个月了,但我在升级 VS 2019 后用 boost 1.70 遇到了同样的问题。我所做的只是删除了第 261 行 'allocate' 调用的第二个参数alt_sstream_impl.hpp,因为它只是一个 hint/optimization,在 c++ 17 中被弃用,现在在 c++ 20 中消失了。幸运的是,它是一个内联方法,所以没有链接器问题。
您可以定义_HAS_DEPRECATED_ALLOCATOR_MEMBERS
即使您选择了 C++20 标准进行编译,它也会重新启用 C++20 中已删除的“分配器内容”。