0

According to: https://en.cppreference.com/w/cpp/utility/source_location

the getters aren't marked as [[nodiscard]].

    constexpr uint_least32_t line() const noexcept;
    constexpr uint_least32_t column() const noexcept;
    constexpr const char* file_name() const noexcept;
    constexpr const char* function_name() const noexcept;

Is there a reason for this? Do they have an effect when called other than the return value?

Alex Guteniev
  • 12,039
  • 2
  • 34
  • 79
  • 1
    Not exactly the same question since `std::move()` predates `[[nodiscard]]` unlike `std::source_location`, but still. Implementors are free to add it as they wish, and probably will. And if they don't, bug them. `[[nodiscard]]` has no normative effect anyway (besides [encouraging](http://eel.is/c++draft/dcl.attr#nodiscard-4.sentence-2) a diagnostic) – Barry Apr 23 '20 at 03:03
  • 1
    `nodiscard` is new and there are very few functions in the standard library where it's specified. My guess nobody got around to propose its introduction and/or being a novelty they are waiting before permanently committing it to the standard library. – bolov Apr 23 '20 at 03:05

0 Answers0