A few months ago I was thinking of submitting this to Boost, but now
I'm actually thinking maybe it should be in the Standard Library.
It won't be approved by the Parallelism & Concurrency study group, for the reasons already explained previously.
Maybe you should propose it for Boost though. The review might be useful.
#if (__cplusplus >= 201700L) || (defined(__has_cpp_attribute) &&
__has_cpp_attribute(nodiscard))
This is not how you test for attributes. For a start, you're assuming that if __cplusplus >= 201703 is true then the attribute is supported, which is not correct. The point of __has_cpp_attribute is to check if the attribute is supported, so that's what you should use. More importantly, if __has_cpp_attribute is not defined then this line will give an error. Using an undefined function-like macro is ill-formed.
You need to do:
#ifdef __has_cpp_attribute
# if __has_cpp_attribute(nodiscard)
# define attrib_nodiscard [[nodiscard]]
# endif
#endif
#ifndef attrib_nodiscard
# define attrib_nodiscard [[nodiscard]]