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

c++ - Can user-defined deduction guides be used to deduce non-deduced context because of nested-name-specifier? - Stack Overflow

programmeradmin4浏览0评论

I know that the following code(down bellow or on godbolt) won't be possible as is, because the nested-name-specifier creates a non-deduced context. But I have hopes that with a user-defined deduction guide, I could get away with it. Can I?

I have tried various deduction guides, but they always have some issues.

template <class T>
struct Outer final
{
    struct Inner
    {
        Inner(Outer<T> o){};
    };
};


template <class T>
using OuterInner = Outer<T>::Inner;


template <typename T>
T foo(OuterInner<T> & engine)
{
    return T();
}


int main()
{
    Outer<int> o;
    OuterInner<int> i(o);
    // works: foo<int>(i);
    return foo(i); // doesn't work
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论