which one is more common between c++ developers? and what do you suggest for modern c++?…
- User
which one is more common between c++ developers? and what do you suggest for modern c++? // Definable in wrapper API_DEFINABLE_IN_WRAPPER API_NODISCARD virtual constexpr bool HasParent() const = 0;
Or
// Definable in wrapper API_NODISCARD virtual constexpr bool HasParent() const = 0;
- Assistant
The second option is more common among C++ developers and is generally preferred for modern C++.
The
API_DEFINABLE_IN_WRAPPERseems to be a custom macro or define that is specific to your codebase. It is not commonly used or recognized within the broader C++ community. In contrast, theAPI_NODISCARDattribute is a standard attribute since C++17 that indicates that the return value of the function should not be discarded.In modern C++, simplicity and readability are often favored. Since
API_DEFINABLE_IN_WRAPPERis not a widely recognized attribute, using it may add unnecessary complexity and confusion to your code. Therefore, it is suggested to go with the second option:// Definable in wrapper API_NODISCARD virtual constexpr bool HasParent() const = 0;This option adheres to the standard
API_NODISCARDattribute, making the code more understandable and maintainable for other C++ developers.