mirror of
https://github.com/fmtlib/fmt.git
synced 2026-02-16 23:29:57 +08:00
Warn about unsafe use of join
This commit is contained in:
parent
d13e5d048d
commit
b5b9317a3c
@ -18,6 +18,12 @@
|
|||||||
|
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
|
||||||
|
#if FMT_HAS_CPP_ATTRIBUTE(clang::lifetimebound)
|
||||||
|
# define FMT_LIFETIMEBOUND [[clang::lifetimebound]]
|
||||||
|
#else
|
||||||
|
# define FMT_LIFETIMEBOUND
|
||||||
|
#endif
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
FMT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
FMT_EXPORT
|
FMT_EXPORT
|
||||||
@ -821,12 +827,12 @@ auto join(Range&& r, string_view sep)
|
|||||||
*
|
*
|
||||||
* **Example**:
|
* **Example**:
|
||||||
*
|
*
|
||||||
* auto t = std::tuple<int, char>{1, 'a'};
|
* auto t = std::tuple<int, char>(1, 'a');
|
||||||
* fmt::print("{}", fmt::join(t, ", "));
|
* fmt::print("{}", fmt::join(t, ", "));
|
||||||
* // Output: 1, a
|
* // Output: 1, a
|
||||||
*/
|
*/
|
||||||
template <typename Tuple, FMT_ENABLE_IF(is_tuple_like<Tuple>::value)>
|
template <typename Tuple, FMT_ENABLE_IF(is_tuple_like<Tuple>::value)>
|
||||||
FMT_CONSTEXPR auto join(const Tuple& tuple, string_view sep)
|
FMT_CONSTEXPR auto join(const Tuple& tuple FMT_LIFETIMEBOUND, string_view sep)
|
||||||
-> tuple_join_view<Tuple, char> {
|
-> tuple_join_view<Tuple, char> {
|
||||||
return {tuple, sep};
|
return {tuple, sep};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user