Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining spaceship operators for glm types #1349

Open
alexanderbock opened this issue Feb 28, 2025 · 0 comments
Open

Defining spaceship operators for glm types #1349

alexanderbock opened this issue Feb 28, 2025 · 0 comments

Comments

@alexanderbock
Copy link

We use glm in our project extensively and have recently added the new spaceship operator to our classes, for example:

    struct CameraNavState {
        static constexpr std::string_view Type = "setNavigationState";

        std::string anchor;
        std::optional<std::string> aim;
        std::string referenceFrame;
        glm::dvec3 position;
        std::optional<glm::dvec3> up;
        std::optional<double> yaw;
        std::optional<double> pitch;

        auto operator<=>(const CameraNavState&) const = default;
    };

while MSVC is totally happy with this, for Clang17 this results in a warning:

/OpenSpace/include/openspace/scene/profile.h:143:14: warning: explicitly defaulted three-way comparison operator is implicitly deleted [-Wdefaulted-function-deleted]
  143 |         auto operator<=>(const CameraNavState&) const = default;
      |              ^
/OpenSpace/include/openspace/scene/profile.h:138:20: note: defaulted 'operator<=>' is implicitly deleted because there is no viable three-way comparison function for member 'position'
  138 |         glm::dvec3 position;
      |                    ^
/OpenSpace/include/openspace/scene/profile.h:143:57: note: replace 'default' with 'delete'

Is there a CMake flag that I'm missing to set that already would enable this? I went through the header and didn't find it, but it seems to me as if enough operators are defined for the compiler to be able to automatically synthesize the spaceship. Alternatively, would it be possible to add that definition to the types?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant