简体   繁体   English

为什么在使用 std::inplace_merge 时,英特尔的 C++ 2022 编译器出现“错误:对‘align_val_t’的引用不明确”?

[英]Why do I get "error: reference to 'align_val_t' is ambiguous" with Intel's C++ 2022 compiler when using std::inplace_merge?

When I try to compile this with the Intel C++ Compiler 2022 toolset for Visual Studio 2022:当我尝试使用适用于 Visual Studio 2022 的 Intel C++ Compiler 2022 工具集对其进行编译时:

#include <algorithm>

int main()
{
    int x = 0;
    std::inplace_merge(&x, &x, &x);
}

I get:我得到:

VC\Tools\MSVC\14.34.31933\include\xmemory(1429,48): error : reference to 'align_val_t' is ambiguous
                _Pbuf = ::operator new (_Size, align_val_t{alignof(_Ty)}, nothrow);
                                               ^
VC\Tools\MSVC\14.34.31933\include\algorithm(7152,57): note: in instantiation of function template specialization 'std::_Optimistic_temporary_buffer<int>::_Optimistic_temporary_buffer<long long>' requested here
    _Optimistic_temporary_buffer<_Iter_value_t<_BidIt>> _Temp_buf{(_STD min)(_Count1, _Count2)};
                                                        ^
VC\Tools\MSVC\14.34.31933\include\algorithm(7160,10): note: in instantiation of function template specialization 'std::inplace_merge<int *, std::less<>>' requested here
    _STD inplace_merge(_First, _Mid, _Last, less<>{});
         ^
Temp.cpp(6,7): note: in instantiation of function template specialization 'std::inplace_merge<int *>' requested here
        std::inplace_merge(&x, &x, &x);
             ^
VC\14.34.31933\include\vcruntime_new.h(27,16): note: candidate found by name lookup is 'std::align_val_t'
    enum class align_val_t : size_t {};
               ^
note: candidate found by name lookup is 'std::align_val_t'

I tried digging through the STL sources, but I can't find where the ambiguity is.我尝试挖掘 STL 来源,但找不到歧义所在。

Why does this error occur?为什么会出现这个错误? And how do I get around it?我该如何解决?

Answering my own question, but it seems to be a bug with precompiled headers .回答我自己的问题,但这似乎是预编译标头的错误 This occurs even if the precompiled header files are empty.即使预编译的 header 文件为空,也会发生这种情况。

Avoiding precompiled headers seems to avoid the issue.避免预编译头文件似乎可以避免这个问题。

If anyone has a better workaround or more details, please do post it.如果有人有更好的解决方法或更多详细信息,请张贴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么`std :: align_val_t`应该限制隐式转换? - Why should `std::align_val_t` restrict implicit conversion? C ++分配器的std :: align_val_t有效的对齐值是什么? - What are the valid alignment values for std::align_val_t for C++ allocators? 在英特尔编译器上使用OpenMP的firstprivate和std :: vector时,为什么会出现未定义的行为? - Why do I get undefined behavior when using OpenMP's firstprivate with std::vector on Intel compiler? 为什么我只是通过删除 using namespace std 就摆脱了错误(对“ ”的引用是模棱两可的); 在 c++ 中? - Why did I get rid of an error (reference to “ ” is ambiguous) just by removing using namespace std; in c++? C ++ STL :: inplace_merge和sort之间的区别是什么 - C++ STL:: what's the difference between inplace_merge and sort 错误:无法在不同模块中定义“enum class std::align_val_t” - Error: cannot define 'enum class std::align_val_t' in different module std :: merge和std :: inplace_merge之间的区别? - Difference between std::merge and std::inplace_merge? 为什么当重新绑定c ++的引用时,编译器不会报告错误 - why when i rebind the reference of c++ , the compiler doesn't report error 如果范围未排序,inplace_merge会做什么? - What does inplace_merge do if the ranges are not sorted? C ++ std :: sort intel编译器错误:访问冲突 - c++ std::sort intel compiler error : access violation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM