Visual Studio 2013 'explicit' keyword bug?

后端 未结 2 1855
轮回少年
轮回少年 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.

    0 讨论(0)
  • 2021-02-07 02:43

    Brought up in the VS forum:

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/af733e56-8045-4553-a9af-6555d02fc2f6/bug-in-vs-2013-support-for-explicit-conversion-operators?forum=visualstudiogeneral

    And reported it as a bug:

    http://connect.microsoft.com/VisualStudio/feedback/details/811334/bug-in-vs-2013-support-for-explicit-conversion-operators

    0 讨论(0)
提交回复
热议问题