0

I'm using gcc-13 and VSCode with intellisense. It does a good job with typed auto complete of members and functions.

template <typename State>
concept IsPerfectInfoState = requires(
    State obj,
    typename State::Types::VectorAction &vec,
    typename State::Types::PRNG &device) {
    {
        obj.terminal
    } -> std::same_as<bool &>;
    {
        obj.row_actions
    } -> std::same_as<typename State::Types::VectorAction &>;
    {
        obj.col_actions
    } -> std::same_as<typename State::Types::VectorAction &>;
    {
        obj.payoff
    } -> std::same_as<typename State::Types::Value &>;
    {
        obj.obs
    } -> std::same_as<typename State::Types::Observation &>;
    {
        obj.prob
    } -> std::same_as<typename State::Types::Probability &>;
    {
        obj.apply_actions(
            typename State::Types::Action{},
            typename State::Types::Action{})
    } -> std::same_as<void>;
    {
        obj.get_actions()
    } -> std::same_as<void>;
} && IsState<State>;

The above asserts members like terminal and methods apply_actions exist. The last && statement even lets autocomplete work with the requirements of IsState.

I also want to assert the existence of typenames or using declarations so that SomeClassWithRealType::R will autocomplete the ::Real, the same way something like this will fill in the T:

struct Foo {
    using T = int;
};

I know you can assert a type is valid

template <typename State>

    concept HasType = requires () {
    typename State::T;

};

But this doesn't work with autocomplete.

Ryan Keathley
  • 49
  • 1
  • 5

0 Answers0