Define SEQUANT_DEPRECATED_MEMBER

Define Documentation

SEQUANT_DEPRECATED_MEMBER(Name, Msg, ...)

Declares a deprecated data member of an aggregate: Name, of a type (named Name##_deprecated_t, derived from DeprecatedMember<Type>) that holds a Type in its value and whose one converting constructor is [[deprecated(Msg)]], so that {.Name = x} is diagnosed with Msg where it is written and the aggregate is otherwise untouched by the deprecation:

struct Options {
  SEQUANT_DESIGNATED_INIT_ONLY;
  std::shared_ptr<const Registry> basis_registry = nullptr;
  /// @deprecated use basis_registry
  SEQUANT_DEPRECATED_MEMBER(space_registry, "use basis_registry",
                            std::shared_ptr<const Registry>);
};
// reading the alias: options.space_registry.value

Note

the member’s default member initializer is {}; a designated initializer that gives it a value, and nothing else, is what warns, so {.Name = nullptr} warns even where nullptr is the default: the spelling is what is deprecated

Note

the member is the declared type, not a Type: code that read the member as a Type reads Name.value instead; the converting constructor never takes the declared type itself, so copying or moving the member is not a use of the deprecated spelling

Parameters:
  • Name – the member’s name

  • Msg – the deprecation message, a string literal

  • ... – the member’s type: a non-const, default-constructible object type (variadic, so that it may contain commas)