Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top