新模板库 [英] New Template library

查看:64
本文介绍了新模板库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

看看这个简单的测试案例:

Looking at this simple test case:

namespace N {
    struct A {};
    template <class T, class U> struct B {
      friend bool operator<=(const T& x, const U& y) { return false; }
    };
    template struct B<A, A>;
  }

  namespace M {
    class C {
      N::A temp1,temp2;
      void foo(){
        temp1 <= temp2;  // 'no matching "<="' , because friend operator is not visible and applicable by xmain
      }  
    };
  }

MSVC编译时没有警告/错误。 Gcc和clang生成错误 

MSVC compiles with no warning/error. Gcc, and clang generate an error 

error: no match for ‘operator<=’ (operand types are ‘N::A’ and ‘N::A’) temp1 <= temp2;

^

新模板库是允许这样还是将其调整为错误?

Will the new template library allow this or will it be adjusted to be an error?

谢谢。

推荐答案

朋友,

这个问题与C ++有关,我会把它移到VC ++论坛,为你提供更好的支持。

This issue is more related to C++, I will move it to VC++ forum for you to get a better support.

感谢您的理解。

 

问候,

Fletcher


这篇关于新模板库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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