|
45 | 45 | # include <sys/types.h> |
46 | 46 | #endif |
47 | 47 |
|
| 48 | +#if defined(__has_cpp_attribute) |
| 49 | +# if __has_cpp_attribute (clang::lifetimebound) |
| 50 | +# define SIMPLECPP_LIFETIMEBOUND [[clang::lifetimebound]] |
| 51 | +# else |
| 52 | +# define SIMPLECPP_LIFETIMEBOUND |
| 53 | +# endif |
| 54 | +#else |
| 55 | +# define SIMPLECPP_LIFETIMEBOUND |
| 56 | +#endif |
| 57 | + |
48 | 58 | #if defined(_MSC_VER) |
49 | 59 | # pragma warning(push) |
50 | 60 | // suppress warnings about "conversion from 'type1' to 'type2', possible loss of data" |
@@ -163,7 +173,7 @@ namespace simplecpp { |
163 | 173 |
|
164 | 174 | Token &operator=(const Token &tok) = delete; |
165 | 175 |
|
166 | | - const TokenString& str() const { |
| 176 | + const TokenString& str() const SIMPLECPP_LIFETIMEBOUND { |
167 | 177 | return string; |
168 | 178 | } |
169 | 179 | void setstr(const std::string &s) { |
@@ -480,25 +490,25 @@ namespace simplecpp { |
480 | 490 | using const_iterator = container_type::const_iterator; |
481 | 491 | using size_type = container_type::size_type; |
482 | 492 |
|
483 | | - size_type size() const { |
| 493 | + size_type size() const SIMPLECPP_LIFETIMEBOUND { |
484 | 494 | return mData.size(); |
485 | 495 | } |
486 | | - iterator begin() { |
| 496 | + iterator begin() SIMPLECPP_LIFETIMEBOUND { |
487 | 497 | return mData.begin(); |
488 | 498 | } |
489 | | - iterator end() { |
| 499 | + iterator end() SIMPLECPP_LIFETIMEBOUND { |
490 | 500 | return mData.end(); |
491 | 501 | } |
492 | | - const_iterator begin() const { |
| 502 | + const_iterator begin() const SIMPLECPP_LIFETIMEBOUND { |
493 | 503 | return mData.begin(); |
494 | 504 | } |
495 | | - const_iterator end() const { |
| 505 | + const_iterator end() const SIMPLECPP_LIFETIMEBOUND { |
496 | 506 | return mData.end(); |
497 | 507 | } |
498 | | - const_iterator cbegin() const { |
| 508 | + const_iterator cbegin() const SIMPLECPP_LIFETIMEBOUND { |
499 | 509 | return mData.cbegin(); |
500 | 510 | } |
501 | | - const_iterator cend() const { |
| 511 | + const_iterator cend() const SIMPLECPP_LIFETIMEBOUND { |
502 | 512 | return mData.cend(); |
503 | 513 | } |
504 | 514 |
|
|
0 commit comments