Skip to content

Commit 6582125

Browse files
committed
added SIMPLECPP_LIFETIMEBOUND
1 parent 7050fb7 commit 6582125

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

simplecpp.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@
6060
# include <sys/types.h>
6161
#endif
6262

63+
#if defined(__has_cpp_attribute)
64+
# if __has_cpp_attribute (clang::lifetimebound)
65+
# define SIMPLECPP_LIFETIMEBOUND [[clang::lifetimebound]]
66+
# else
67+
# define SIMPLECPP_LIFETIMEBOUND
68+
# endif
69+
#else
70+
# define SIMPLECPP_LIFETIMEBOUND
71+
#endif
72+
6373
static bool isHex(const std::string &s)
6474
{
6575
return s.size()>2 && (s.compare(0,2,"0x")==0 || s.compare(0,2,"0X")==0);

simplecpp.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@
4242
# define SIMPLECPP_LIB
4343
#endif
4444

45+
#if defined(__has_cpp_attribute)
46+
# if __has_cpp_attribute (clang::lifetimebound)
47+
# define SIMPLECPP_LIFETIMEBOUND [[clang::lifetimebound]]
48+
# else
49+
# define SIMPLECPP_LIFETIMEBOUND
50+
# endif
51+
#else
52+
# define SIMPLECPP_LIFETIMEBOUND
53+
#endif
54+
4555
#if defined(_MSC_VER)
4656
# pragma warning(push)
4757
// suppress warnings about "conversion from 'type1' to 'type2', possible loss of data"
@@ -611,6 +621,8 @@ namespace simplecpp {
611621
# pragma warning(pop)
612622
#endif
613623

624+
#undef SIMPLECPP_LIFETIMEBOUND
625+
614626
#undef SIMPLECPP_LIB
615627

616628
#endif

test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
#error "SIMPLECPP_TEST_SOURCE_DIR is not defined."
2727
#endif
2828

29+
#if defined(__has_cpp_attribute)
30+
# if __has_cpp_attribute (clang::lifetimebound)
31+
# define SIMPLECPP_LIFETIMEBOUND [[clang::lifetimebound]]
32+
# else
33+
# define SIMPLECPP_LIFETIMEBOUND
34+
# endif
35+
#else
36+
# define SIMPLECPP_LIFETIMEBOUND
37+
#endif
38+
2939
#define STRINGIZE_(x) #x
3040
#define STRINGIZE(x) STRINGIZE_(x)
3141

0 commit comments

Comments
 (0)