4

I am trying to compile codes written in c++17 with c++20. But the following function getTest() doesn't work anymore:

struct Test
{
    Test() noexcept = default;
    Test (const Test&) noexcept = default;
    ~Test() noexcept = default;
    int a, b;
};

Test getTest()
{
    return { 1, 2 };
}

In c++17 getTest compiles, but with 20 the compiler complains that "No matching constructor..."

Is it correct to fall back to return Test(1, 2), given that I make a custom constructor with Test (int first, int second)

Thinium
  • 171
  • 1
  • 14

0 Answers0