In the same version, clang ++ do not agree with the reality of direct vector initialization between Mint and Debian, OSX

I seem to have written code that works as intended on OSX (Sierra) and Debian (stable), with different versions of clang ++, but doesn't want to compile on Mint (Cinnamon) with the same versions of clang ++.

As far as I know, this piece of code is valid C ++ 14 (and has been configured with most of the code I'm working on):

#include <iostream>
#include <map>
#include <vector>

using frobs = std::map<int, int>;

struct sampleData {
  frobs in;
  int out;
};

int main(void) {
  std::vector<sampleData> tests{
      {{}, 0},
      {{{1, 2}}, 3},
  };

  for (const auto &tt : tests) {
    for (const auto &t : tt.in) {
      std::cout << t.first << "\n";
    }
  }

  return 0;
}

And compile it on Debian with clang ++ 3.5 as follows:

clang++ -std=c++14 -stdlib=libc++ initialiser.cpp -o initialiser

... works and does not complain. However, on Mint Cinnamon with the same version of clang ++:

clang++-3.5 -std=c++14 -stdlib=libc++ initialiser.cpp -o initialiser

Complains in this way:

    initialiser.cpp:14:27: error: no matching constructor for initialization of 'std::vector<sampleData>'
  std::vector<sampleData> tests{

See http://paste.ubuntu.com/24494631/ for a complete error.

, , , , OSX clang++ Xcode. lib++ 1 lib++ - dev Mint, Debian, , clang++ Mint, Debian.

, , clang++ , , g++ ( , -std = ++ 11 omit -stdlib = lib++, g++).

, , :

  • ?
  • Mint - ?
  • ? ?
+4

Source: https://habr.com/ru/post/1676083/


All Articles