theRockLiu / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

奇怪的tuple 编译错误 #235

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
在Vista sp2 vs2008 sp1  gtest-1.4.0 中 定义一个类 使用  
tuple,若如下定义 则可顺
利编译通过
class CombineTest:
    public TestWithParam<::std::tr1::tuple<int, unsigned long 
long,DWORD,unsigned short >> {};
INSTANTIATE_TEST_CASE_P(DataStoreCombineTest, CombineTest,
                         Combine(                   
                    Values(2),
                Values(8, 9, 10),
                Values(100, 200, 300),
                Values(45, 46, 47)
                ));
但是若修改成这样
class CombineTest:
    public TestWithParam<::std::tr1::tuple<unsigned int, unsigned long 
long,DWORD,unsigned short >> {};
INSTANTIATE_TEST_CASE_P(DataStoreCombineTest, CombineTest,
                         Combine(                   
                    Values(2),
                Values(8, 9, 10),
                Values(100, 200, 300),
                Values(45, 46, 47)
                ));

则编译出错
error C2664: “testing::internal::ParamGenerator<T>::ParamGenerator(const 
testing::internal::ParamGenerator<T> &)”: 不能将参数 1 从
“testing::internal::ParamGenerator<T>”转换为“const 
testing::internal::ParamGenerator<T> &”
1>        with
1>        [
1>            T=unsigned int
1>        ]
1>        and
1>        [
1>            T=int
1>        ]
1>        and
1>        [
1>            T=unsigned int
1>        ]
1>        原因如下: 
无法从“testing::internal::ParamGenerator<T>”转换为
“const testing::internal::ParamGenerator<T>”
1>        with
1>        [
1>            T=int
1>        ]
1>        and
1>        [
1>            T=unsigned int
1>        ]
1>        
没有可用于执行该转换的用户定义的转换运算符,或者无法��
�用该运算符
1>        gtest-1.4.0\include\gtest\internal\gtest-param-util-generated.h
(4655): 参见对正在编译的函数 模板 实例化
“testing::internal::ValueArray1<T1>::operator 
testing::internal::ParamGenerator<T>(void) const<unsigned int>”的引用
1>        with
1>        [
1>            T1=int,
1>            T=unsigned int
1>        ]

同样的道理 <::std::tr1::tuple<WORD, unsigned long long,DWORD,unsigned 
short 
>>  ,<::std::tr1::tuple<unsigned short, unsigned long long,DWORD,unsigned 
short >>  等等都会提示上面的错误,似乎第一个必须是 Int 
有什么建议吗?

Original issue reported on code.google.com by wangqian...@gmail.com on 19 Dec 2009 at 7:08

GoogleCodeExporter commented 9 years ago
抱歉,似乎重新启动一下操作系统以后,可怜的VS 
不会发疯了,不知该如何撤回这个问题。

Original comment by wangqian...@gmail.com on 19 Dec 2009 at 8:24

GoogleCodeExporter commented 9 years ago
The user fixed the problem by rebooting.

Original comment by w...@google.com on 21 Dec 2009 at 6:59