Skip to content

Commit 4bd5e10

Browse files
committed
added SIMPLECPP_LIFETIMEBOUND
1 parent ad82f98 commit 4bd5e10

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"
@@ -602,6 +612,8 @@ namespace simplecpp {
602612
# pragma warning(pop)
603613
#endif
604614

615+
#undef SIMPLECPP_LIFETIMEBOUND
616+
605617
#undef SIMPLECPP_LIB
606618

607619
#endif

test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
#error "SIMPLECPP_TEST_SOURCE_DIR is not defined."
2323
#endif
2424

25+
#if defined(__has_cpp_attribute)
26+
# if __has_cpp_attribute (clang::lifetimebound)
27+
# define SIMPLECPP_LIFETIMEBOUND [[clang::lifetimebound]]
28+
# else
29+
# define SIMPLECPP_LIFETIMEBOUND
30+
# endif
31+
#else
32+
# define SIMPLECPP_LIFETIMEBOUND
33+
#endif
34+
2535
#define STRINGIZE_(x) #x
2636
#define STRINGIZE(x) STRINGIZE_(x)
2737

0 commit comments

Comments
 (0)