Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· openaiHugging Face Suzhen/CodeChat

which one is more common between c++ developers? and what do you suggest for modern c++?…

  1. 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;

  2. Assistant

    The second option is more common among C++ developers and is generally preferred for modern C++.

    The API_DEFINABLE_IN_WRAPPER seems 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, the API_NODISCARD attribute 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_WRAPPER is 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_NODISCARD attribute, making the code more understandable and maintainable for other C++ developers.