0

The error message of gcc 4.9.2 is:

could not convert from '<brace-enclosed initializer list>' to 'std::vector<std::pair<float, float> >'

of this code:

vector<pair<GLfloat, GLfloat>> LightOneColorsPairVec {{0.5f, 0.5f, 0.5f, 1.0f}, {0.0f, 0.0f, 1.0f, 1.0f}};

The code is compiled with 'std=c++11' compiler flag.

Praetorian
  • 106,671
  • 19
  • 240
  • 328
moonwalker
  • 1,157
  • 1
  • 18
  • 34

2 Answers2

2

First of all because std::pair doesn't have constructor that takes a std::initializer_list. Secondly because std::pair is a pair, it only have two values, not four.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • 1
    You do not need a `initializer_list` constructor to use the braced form of initialization, so I'm not sure I'm seeing what the point of the first sentence is. – T.C. May 30 '15 at 23:53
0

As Joachim Pileborg pointed out pairs are not similar to vectors, so I converted the code to this:

vector<vector<vector<GLfloat>>> LightColorsVec {{{0.5f, 0.5f, 0.5f, 1.0f}, {0.0f, 0.0f, 1.0f, 1.0f}}};

And it works for multiple light sources now.

moonwalker
  • 1,157
  • 1
  • 18
  • 34