最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - Satisfaction of atomic constraint '__constructible ...' depends on itself - Stack Overflow

programmeradmin2浏览0评论

This code does not compile with gcc14 with -std=c++20.

#include <tuple>
#include <type_traits>

struct Foo
{
    template<typename T>
    Foo(T) {}
};

struct Bar
{
    Bar(std::tuple<Foo>) {}
};

int main()
{
    return std::is_constructible_v<Foo, Bar>;
}

Errors include

tuple:979:42: error: satisfaction of atomic constraint '__constructible<_UTypes ...>() [with _Elements = {_Elements ...}; _UTypes = {_UTypes ...}]' depends on itself
tuple:989:42: error: 'static consteval bool std::tuple< <template-parameter-1-1> >::__constructible() [with _UTypes = {Bar}; _Elements = {Foo}]' called in a constant expression before its definition is complete
tuple:989:42: error: satisfaction value of atomic constraint '__constructible<_UTypes ...>() [with _Elements = {Foo}; _UTypes = {Bar}]' changed from '<expression error>' to 'true'

Full output could be seen here:

This code compiles with -std=c++17 or with gcc13 or older. Putting explicit on Bar constructor also resolves the problem.

Does anyone know what is happening here or how this can be worked around, besides putting explicit on Bar?

Some context: the problem was detected while trying to copy Bar.

Bar b1{Foo{0}};
Bar b2{b1};
发布评论

评论列表(0)

  1. 暂无评论