Skip to content

C++20 issues #30

@davidcerny

Description

@davidcerny

Issue from revbayes/revbayes#837 (comment) by @bredelings:

It looks like NCL has a few problems with C++20. I wonder if the upstream NCL fixes these.

(Hmm... it seems like it doesn't? So I guess this isn't really related to the current PR, so maybe I should move this comment to its own issue)

The issue seems to be that nxscharactersblock.h does

class NxsDiscreteDatatypeMapper;

class NxsCharactersBlock
{
...
		typedef std::pair<NxsDiscreteDatatypeMapper, NxsUnsignedSet> DatatypeMapperAndIndexSet;
		typedef std::vector<DatatypeMapperAndIndexSet> VecDatatypeMapperAndIndexSet;
...
};

class NxsDiscreteDatatypeMapper
{
...
		NxsDiscreteDatatypeMapper(NxsCharactersBlock::DataTypesEnum datatypeE, bool hasGaps);
...
};

The error is because the definition for NxsDiscreteDatatypeMapper is not known when std::pair<NxsDiscreteDatatypeMapper, NxsUnsignedSet> is first used. This was allowed in C++17 in some circumstances, but is not longer allowed in C++20.

We could simply move the definition of NxsDiscreteDatatypeMapper above the definition of NxsCharactersBlock, except that NxsDiscreteDatatypeMapper also references NxsCharactersBlock through NxsCharactersBlock::DataTypesEnum, creating a reference loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions