在成员初始化器列表或非静态数据成员初始化器内的c2797列表初始化没有实现。

时间:2023-01-31 22:46:55

I m getting the following error in visual studio 2013 when i try to compile my project.

当我试图编译我的项目时,我在visual studio 2013中得到了以下错误。

c2797:List initialization inside member initializer list or non static data member initializer not implemented.

c2797:在成员初始化器列表或非静态数据成员初始化器中列出未实现的初始化。

Here is the piece of code for which it is throwing the above compiler error.

下面是它抛出上述编译器错误的代码。

====sample.h====

= = = = sample.h = = = =

enum class Process
{


  TUNNEL_IP_VERSION,  // Tunnel::IPVersion::Type
  PADDING_BYTE,
  IP_ADDRESS_FIT_ACTUAL_SIZE,
  IP_ADDRESS_FIT_IPv6_SIZE,
  PORT_NUMBER,
};

using ProcessingOrder = std::vector<Process>;

const ProcessingOrder m_ProcessingOrder =
{


  Process::TUNNEL_IP_VERSION,
  Process::PADDING_BYTE,
  Process::IP_ADDRESS_FIT_IPv6_SIZE,
  Process::PORT_NUMBER
};

Eventhough VS2013 supports c++11 feature - intialize list , why it is throughing the above error !? How to get off with this situation? What do i need to change in the code to fix this?

Thanks for your answer. That works great. I have a similar situation for the below statement as well.

谢谢你的回答。伟大的工作。对于下面的语句,我也有类似的情况。

m_Attribute{SSL_CTX_new(g_SSLChoice[version].m_pfSSLMethod()), 0, 0}
  {

where, m_Attribute is,

在那里,m_Attribute

struct{
         SSL_CTX* const m_pContext;
         Socket* m_pSocket;
         X509* m_pCertificate;
         }m_Attribute;

SSL_CTX_new, is a standard definition in ssl.have
g_SSLChoice is,

SSL_CTX_new是ssl中的标准定义。g_SSLChoice是

g_SSLChoice[CloudSSL::TLSv1_2 + 1] =
  {
    /* [SSLv23] = */ {&SSLv3_client_method, 0},
    /* [SSLv3] = */ {&SSLv23_client_method, SSL_OP_NO_SSLv2},
    /* [TLSv1] = */ {&TLSv1_client_method, SSL_OP_NO_SSLv3},
    /* [TLSv1_1] = */ {&TLSv1_1_client_method, SSL_OP_NO_TLSv1},
    /* [TLSv1_2] = */ {&TLSv1_2_client_method, SSL_OP_NO_TLSv1_1}
  };

in which,

在这,

class CloudSSL : public Util::Thread
  {

public: enum Version
        {
          // SSLv2,  // Not supported
          SSLv23,
          SSLv3,
          TLSv1,
          TLSv1_1,
          TLSv1_2
        };

And finally m_pfSSLMethod is, const SSL_METHOD* (*m_pfSSLMethod)();

最后是m_pfSSLMethod, const SSL_METHOD* (*m_pfSSLMethod)();

1 个解决方案

#1


4  

Visual Studio did not implement this feature yet. An workaround can be found here

Visual Studio还没有实现这个功能。在这里可以找到一个变通方法。

You can just use

你可以使用

const ProcessingOrder m_ProcessingOrder = ProcessingOrder
{
  Process::TUNNEL_IP_VERSION,
  Process::PADDING_BYTE,
  Process::IP_ADDRESS_FIT_IPv6_SIZE,
  Process::PORT_NUMBER
};

For your second case.

你的第二个案例。

struct Attribute_t{
         SSL_CTX* const m_pContext;
         Socket* m_pSocket;
         X509* m_pCertificate;
         }m_Attribute;

then just

那就

m_Attribute = Attribute_t{SSL_CTX_new(g_SSLChoice[version].m_pfSSLMethod()),
0, 0}

#1


4  

Visual Studio did not implement this feature yet. An workaround can be found here

Visual Studio还没有实现这个功能。在这里可以找到一个变通方法。

You can just use

你可以使用

const ProcessingOrder m_ProcessingOrder = ProcessingOrder
{
  Process::TUNNEL_IP_VERSION,
  Process::PADDING_BYTE,
  Process::IP_ADDRESS_FIT_IPv6_SIZE,
  Process::PORT_NUMBER
};

For your second case.

你的第二个案例。

struct Attribute_t{
         SSL_CTX* const m_pContext;
         Socket* m_pSocket;
         X509* m_pCertificate;
         }m_Attribute;

then just

那就

m_Attribute = Attribute_t{SSL_CTX_new(g_SSLChoice[version].m_pfSSLMethod()),
0, 0}