|
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) { |
@@ -483,25 +493,25 @@ namespace simplecpp { |
483 | 493 | using const_iterator = container_type::const_iterator; |
484 | 494 | using size_type = container_type::size_type; |
485 | 495 |
|
486 | | - size_type size() const { |
| 496 | + size_type size() const SIMPLECPP_LIFETIMEBOUND { |
487 | 497 | return mData.size(); |
488 | 498 | } |
489 | | - iterator begin() { |
| 499 | + iterator begin() SIMPLECPP_LIFETIMEBOUND { |
490 | 500 | return mData.begin(); |
491 | 501 | } |
492 | | - iterator end() { |
| 502 | + iterator end() SIMPLECPP_LIFETIMEBOUND { |
493 | 503 | return mData.end(); |
494 | 504 | } |
495 | | - const_iterator begin() const { |
| 505 | + const_iterator begin() const SIMPLECPP_LIFETIMEBOUND { |
496 | 506 | return mData.begin(); |
497 | 507 | } |
498 | | - const_iterator end() const { |
| 508 | + const_iterator end() const SIMPLECPP_LIFETIMEBOUND { |
499 | 509 | return mData.end(); |
500 | 510 | } |
501 | | - const_iterator cbegin() const { |
| 511 | + const_iterator cbegin() const SIMPLECPP_LIFETIMEBOUND { |
502 | 512 | return mData.cbegin(); |
503 | 513 | } |
504 | | - const_iterator cend() const { |
| 514 | + const_iterator cend() const SIMPLECPP_LIFETIMEBOUND { |
505 | 515 | return mData.cend(); |
506 | 516 | } |
507 | 517 |
|
|
0 commit comments