1

I'm trying to make a very simple gui for a vst plugin using vstgui 4.0. I'm using Visual Studio 2012 Express. When I build it, I'm getting an error from one of the sdk files. The error is:

error C2664: 'std::make_pair' : cannot convert parameter 1 from 'const VSTGUI::CViewAttributeID' to 'VSTGUI::CViewAttributeID &&' c:\sdks\vst3 sdk\vstgui4\vstgui\lib\cview.cpp 691 1 VST

Its coming from the 'attributes.insert...' line in cview.cpp:

bool CView::setAttribute (const CViewAttributeID id, const int32_t inSize, const void* inData)
{
    if (inData == 0 || inSize <= 0)
        return false;
    CViewAttributeConstIterator it = attributes.find (id);
    if (it != attributes.end ())
        it->second->updateData (inSize, inData);
    else
        attributes.insert (std::make_pair<CViewAttributeID, CViewAttributeEntry*> (id, new CViewAttributeEntry (inSize, inData)));
    return true;
}

What can I do to fix this? Is there some way I'm supposed to suppress this error?

Benjamin Lindley
  • 101,917
  • 9
  • 204
  • 274
Rob Allsopp
  • 3,309
  • 5
  • 34
  • 53
  • 1
    Replace `std::make_pair` with `std::pair`. – Kerrek SB Dec 29 '13 at 01:23
  • So is this a bug in the sdk? I'm not supposed to modify anything in this file. – Rob Allsopp Dec 29 '13 at 01:27
  • 2
    No, it's strictly a bug between keyboard and chair (not necessarily *your* chair). Don't specify function template arguments that are meant to be deduced. It was always wrong to do so, but going from C++03 to C++11 introduced a breaking change in `make_pair` that would surface this error. It's a "deserves to be broken" kind of breaking change. – Kerrek SB Dec 29 '13 at 01:28
  • 1
    Please [watch this video](http://channel9.msdn.com/Events/GoingNative/2013/Don-t-Help-the-Compiler) before resuming this post. – Kerrek SB Dec 29 '13 at 01:28

1 Answers1

3

There was a breaking change in make_pair when used incorrectly in C++11: if you specify argument types, it means something different in C++11 than in C++03.

To fix this, change std::make_pair that specifies argument types to std::pair and leave everything else alone.

Alternatively, remove the type arguments to make_pair, as you should basically never pass them. This can, however, change how things work if the old code was doimg something quirky (in the above case it is safe I think).

The first solution will, however, mimic C++03s behavior in C++11 closer, in case they did something strange, so is safest.

std::make_pair without <> after them you should leave alone.

This breaking change is related to perfect forwarding efficiency improvements in C++11 and support for move only types.

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524