Visual Studio 2013 'explicit' keyword bug?

后端 未结 2 1856
轮回少年
轮回少年 2021-02-07 02:04

Consider the following program:

#include 

class A
{
public:
  A( ) { std::cout << \"A()\\n\"; }

  A( A& ) = delete;

  A( int i ) { s         


        
2条回答
  •  情深已故
    2021-02-07 02:21

    This is definitely a bug in Visual C++. According to standard:

    12.3.2 Conversion functions [class.conv.fct]

    2 - A conversion function may be explicit (7.1.2), in which case it is only considered as a user-defined conversion for direct-initialization (8.5) in certain contexts (13.3.1.4, 13.3.1.5, 13.3.1.6).

    and there is no direct-initialization in your example.

    Other C++ compilers such as GCC and Clang report an error in this case.

提交回复
热议问题