'Clang-Format wrongly detects & operator (boost serialization)

I tried to apply clang-format (11) on a file containing a boost serializable file with content along the lines

class MyClass
{
    int _myNumber;
    int &_myRefNumber;

    friend class boost::serialization::access;
    template <typename Archive>
    void serialize(Archive& ar, const unsigned int /*version*/) const
    {
        ar & _myNumber;
    }
}

now suppose I like references on the left, I set PointerAlignment : Left and get

class MyClass
{
    int _myNumber;
    int& _myRefNumber;

    friend class boost::serialization::access;
    template <typename Archive>
    void serialize(Archive& ar, const unsigned int /*version*/) const
    {
        ar& _myNumber;
    }
}

which is correct for the refrence, but also nastily moves the & operator to the left. Is there any graceful way with clang-format to keep the operator with whitespaces while moving references? For now the only way I see is to disable clang-format for those lines.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source