在统一初始化中初始化一个向量<std::string>

Initializing a vector<std::string> in uniform initialization

我正在使用以下代码

class test
{
public:
    test(std::vector<std::string> str)
    {
        auto a = str[0];
        a = "B";
    }
    test()
    {
    }
    const std::multimap<int,  std::multimap<int, test>> _var= {
        {0x01,  {
                    {
                        0x0f, std::vector<std::string>{"A", "B", "C", "D"}
                    }
        }
        }
    };
};

int main()
{
    test t;
    std::cout << "Done";
}

上面的代码构建良好,但是当我 运行 它时,我的访问权限很差。我附上了调用堆栈。为什么我会收到该错误的任何建议?或者我该如何解决?似乎它是一个恒定的循环。

你有一个无限递归的情况,导致堆栈溢出。

创建 test 的实例 -->
初始化 _var -->
创建 test 的实例 -->
初始化 _var -->

等等。