std-source-location

std::source_location as non type template parameter

痞子三分冷 提交于 2021-02-08 05:34:26
问题 In my infinite quest to push limits of what can be used as non type template parameter I was trying to see if I can use std::source_location as non type template parameter. That failed with a weird message, since I presume source_location is some magical struct... type 'std::experimental::source_location' of non-type template parameter is not a structural type It failed, so I tried to workaround that with using .file_name, but that also fails (godbolt). note: candidate template ignored:

std::source_location as non type template parameter

♀尐吖头ヾ 提交于 2021-02-08 05:34:12
问题 In my infinite quest to push limits of what can be used as non type template parameter I was trying to see if I can use std::source_location as non type template parameter. That failed with a weird message, since I presume source_location is some magical struct... type 'std::experimental::source_location' of non-type template parameter is not a structural type It failed, so I tried to workaround that with using .file_name, but that also fails (godbolt). note: candidate template ignored:

How could std::experimental::source_location be implemented?

删除回忆录丶 提交于 2020-08-24 06:03:06
问题 C++ Extensions for Library Fundamentals, Version 2 (N4564) introduces the type std::experimental::source_location. § 14.1.2 [reflection.src_loc.creation] says: static constexpr source_location current() noexcept; Returns: When invoked by a function call (C++14 § 5.2.2) whose postfix-expression is a (possibly parenthesized) id-expression naming current , returns a source_location with an implementation-defined value. The value should be affected by #line (C++14 § 16.4) in the same manner as

Does C++20 mandate source code being stored in files?

断了今生、忘了曾经 提交于 2020-06-09 08:09:27
问题 A slightly strange question, however, if I remember correctly, C++ source code doesn't require a file system to store its files. Having a compiler that scans handwritten papers via a camera would be a conforming implementation. Although practically not making that much sense. However C++20 now adds source location with file_name. Does this now imply that source code should always be stored in a file? 回答1: No, source code doesn't have to come from a file (nor go to a file). You can compile

Does C++20 mandate source code being stored in files?

扶醉桌前 提交于 2020-06-09 08:08:51
问题 A slightly strange question, however, if I remember correctly, C++ source code doesn't require a file system to store its files. Having a compiler that scans handwritten papers via a camera would be a conforming implementation. Although practically not making that much sense. However C++20 now adds source location with file_name. Does this now imply that source code should always be stored in a file? 回答1: No, source code doesn't have to come from a file (nor go to a file). You can compile

Does C++20 mandate source code being stored in files?

喜你入骨 提交于 2020-06-09 08:08:39
问题 A slightly strange question, however, if I remember correctly, C++ source code doesn't require a file system to store its files. Having a compiler that scans handwritten papers via a camera would be a conforming implementation. Although practically not making that much sense. However C++20 now adds source location with file_name. Does this now imply that source code should always be stored in a file? 回答1: No, source code doesn't have to come from a file (nor go to a file). You can compile

How to use source_location in a variadic template function?

我怕爱的太早我们不能终老 提交于 2019-11-27 10:44:57
问题 The C++20 feature std::source_location is used to capture information about the context in which a function is called. When I try to use it with a variadic template function, I encountered a problem: I can't see a place to put the source_location parameter. The following doesn't work because variadic parameters have to be at the end: // doesn't work template <typename... Args> void debug(Args&&... args, const std::source_location& loc = std::source_location::current()); The following doesn't