Skip to content
Discussion options

You must be logged in to vote

This is related to this issue: #1821. However, the constraint you want is supported because it is a constraint on your inner struct.

Full demo: compiler explorer link

#include <iostream>

#include "glaze/glaze.hpp"

struct Inner {
    std::optional<std::string> x;
    std::optional<std::string> y;
};

struct Outer {
    int x;
    Inner inner;
    int y;
};

template <>
struct glz::meta<Outer> {
    using T = Outer;
    static constexpr auto inner_constraint = [](const T&, const Inner& inner) {
        if (inner.x && inner.y) {
            return true;
        } else if ((not inner.x) && (not inner.y)) {
            return true;
        }
        return false;
    };

    static constexpr a…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by StormLord07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants