GMOCKing接口时std :: any的类型不完整 [英] incomplete type for std::any when GMOCKing interface

查看:79
本文介绍了GMOCKing接口时std :: any的类型不完整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码段存在一个非常奇怪的编译问题:

I have a very weird compilation problem with this snippet:

#include <any>
#include <gmock/gmock.h>


struct Class
{
    virtual std::any get(int, int) = 0;
};


struct MockClass: Class
{
    MOCK_METHOD2(get, std::any(int, int));
};


int foo()
{
    MockClass dd;
}

错误gcc 9.1.0:

Error gcc 9.1.0:

/usr/include/c++/9.1.0/type_traits:131:12: error: incomplete type ‘std::is_copy_constructible<testing::internal::ReferenceOrValueWrapper<std::any> >’ used in nested name specifier

clang 8.0.0:

clang 8.0.0:

/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.1.0/../../../../include/c++/9.1.0/type_traits:132:31: error: no member named 'value' in 'std::is_copy_constructible<testing::internal::ReferenceOrValueWrapper<std::any> >'

如果我替换 std :: any std :: string 或任何其他常见类型的c>代码进行编译。

If I replace std::any with std::string or any other common type, code compiles.

推荐答案

这是libstdc ++错误 90415

This is libstdc++ bug 90415.

我不确定导致此问题的 std :: any 是什么。请注意,您的示例在使用libstdc ++的clang上失败,但在使用libc ++的示例上成功。

I am not sure what it is about std::any that causes this problem. Note that your example fails on clang using libstdc++, but succeeds when using libc++.

这篇关于GMOCKing接口时std :: any的类型不完整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆