You can declare a class with the [[nodiscard]] attribute. It may be useful when you know from the semantics of this class that whenever it's returned from a function, it must be used for something. I have exactly this case, and it would be very convenient to tag the class with [[nodiscard]] instead of each individual function that returns it. However, there's one complication. This is the type that I need to make [[nodiscard]]:
using ConnectionStruct = std::pair<std::shared_ptr<CMutex>, std::shared_ptr<SignalFunction>>;
Is there a syntax to mark my ConnectionStruct as [[nodiscard]]?
[[nodiscard]]cannot be applied to aliases. Only to:Emphasis added.