Home perfect forwarding function deduced conflicting error
Reply: 0

perfect forwarding function deduced conflicting error

user542
1#
user542 Published in July 21, 2018, 1:52 pm

I am testing perfect forwarding, and I dont understand why TEST_EQ(string("olleH"), s) compile failed, but string("olleH") == s compile pass. How do I fix my TEST_EQ function here?

template<typename S>
static bool TEST_EQ(S&& a, S&& b) 
{
    return forward<S>(a) == forward<S>(b);      
}


int main()
{
 string s= "Hello";

 cout << TEST_EQ(string("olleH"), s) << endl;
 cout << (string("olleH") == s);

}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.472054 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO