Stefan Deller
Stefan Deller

Reputation: 55

Cannot compile new QuickFix version in C++20

I have worked with a older version of QuickFix. Now I have updated my code to C++20 and installed the newest version of QuickFix. I have downloaded the code from https://github.com/quickfix/quickfix. Now I get compiler errors: FIX::FieldBase" has no member "first" FIX::FieldBase" has no member "second"

This is the code that works with the old version of QuickFix, but not with the actual version:

const FIX::FieldMap& fieldMap
...
for (auto itr = fieldMap.begin(), end = fieldMap.end(); itr != end; ++itr)
{
    if (itr->second.getLength())
    {
        ...
    }
}   
...

The problem is the following line in FieldMap.h:

typedef std::vector < FieldBase, ALLOCATOR< FieldBase > > Fields;

This the a except from the old version:

typedef std::multimap < int, FieldBase, message_order, ALLOCATOR<std::pair<const int,FieldBase> > > Fields;

It seems that multimap is replaced by a vector. Can anybody give an advice?

Upvotes: 0

Views: 214

Answers (1)

Timon van der Berg
Timon van der Berg

Reputation: 586

The map from int to FieldBase has been replaced by a vector<FieldBase>, which is in some sense a map from int (index) to FieldBase too.

Just replace

itr->second.getLength();

with

itr->getLength();

Depending on the context you might be able to replace the loop with a simpler range-based for-loop which does not mention iterators:

for (const FieldBase &fb : fieldMap) {
    fb.getLength();
}

Upvotes: 1

Related Questions