Skip to content

Commit 1564242

Browse files
committed
fix for old clang?
1 parent 0140a8a commit 1564242

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

include/ctre/return_type.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,15 @@ template <size_t Id, typename Name = void> struct captured_content {
8080
} else { // I'm doing this to avoid warning about dead code
8181
#endif
8282

83-
#if __cpp_lib_to_address >= 201711L
84-
return std::to_address(_begin);
85-
#else
86-
return &*_begin;
87-
#endif
83+
if constexpr (std::is_pointer_v<Iterator>) {
84+
return _begin;
85+
} else {
86+
#if __cpp_lib_to_address >= 201711L
87+
return std::to_address(_begin);
88+
#else
89+
return &*_begin;
90+
#endif
91+
}
8892

8993
#if __cpp_char8_t >= 201811
9094
}

single-header/ctre-unicode.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,11 +3368,15 @@ template <size_t Id, typename Name = void> struct captured_content {
33683368
} else { // I'm doing this to avoid warning about dead code
33693369
#endif
33703370

3371-
#if __cpp_lib_to_address >= 201711L
3372-
return std::to_address(_begin);
3373-
#else
3374-
return &*_begin;
3375-
#endif
3371+
if constexpr (std::is_pointer_v<Iterator>) {
3372+
return _begin;
3373+
} else {
3374+
#if __cpp_lib_to_address >= 201711L
3375+
return std::to_address(_begin);
3376+
#else
3377+
return &*_begin;
3378+
#endif
3379+
}
33763380

33773381
#if __cpp_char8_t >= 201811
33783382
}

single-header/ctre.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,11 +3365,15 @@ template <size_t Id, typename Name = void> struct captured_content {
33653365
} else { // I'm doing this to avoid warning about dead code
33663366
#endif
33673367

3368-
#if __cpp_lib_to_address >= 201711L
3369-
return std::to_address(_begin);
3370-
#else
3371-
return &*_begin;
3372-
#endif
3368+
if constexpr (std::is_pointer_v<Iterator>) {
3369+
return _begin;
3370+
} else {
3371+
#if __cpp_lib_to_address >= 201711L
3372+
return std::to_address(_begin);
3373+
#else
3374+
return &*_begin;
3375+
#endif
3376+
}
33733377

33743378
#if __cpp_char8_t >= 201811
33753379
}

0 commit comments

Comments
 (0)