Skip to content

Commit 9cb4a7f

Browse files
aengusjiangjeremy-rifkinAengus.Jiang
authored
compatible for c++11 but GCC < 5 (#267)
compatible for c++11 but GCC < 5 such as gcc 4.8.5 --------- Co-authored-by: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> Co-authored-by: Aengus.Jiang <jiangyinglin@surfilter.com>
1 parent afdc61c commit 9cb4a7f

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,8 @@ jobs:
732732
-DCMAKE_CXX_COMPILER=g++-4.8 \
733733
-DCMAKE_C_COMPILER=gcc-4.8 \
734734
-DCPPTRACE_WERROR_BUILD=On \
735-
-DCPPTRACE_STD_FORMAT=Off \
736-
-DCPPTRACE_BUILD_TESTING=On
735+
-DCPPTRACE_STD_FORMAT=Off
737736
ninja
738-
./unittest
739737
740738
unittest-windows-32-bit:
741739
runs-on: windows-2022

src/utils/io/base_file.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace detail {
1717
template<
1818
typename T,
1919
typename std::enable_if<
20-
std::is_standard_layout<T>::value && std::is_trivially_copyable<T>::value && !is_span<T>::value,
20+
std::is_standard_layout<T>::value && is_trivially_copyable<T>::value && !is_span<T>::value,
2121
int
2222
>::type = 0
2323
>
@@ -33,7 +33,7 @@ namespace detail {
3333
template<
3434
typename T,
3535
typename std::enable_if<
36-
std::is_standard_layout<T>::value && std::is_trivially_copyable<T>::value,
36+
std::is_standard_layout<T>::value && is_trivially_copyable<T>::value,
3737
int
3838
>::type = 0
3939
>

src/utils/span.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace detail {
8585
template<
8686
typename T,
8787
typename std::enable_if<
88-
std::is_standard_layout<T>::value && std::is_trivially_copyable<T>::value && !is_span<T>::value,
88+
std::is_standard_layout<T>::value && is_trivially_copyable<T>::value && !is_span<T>::value,
8989
int
9090
>::type = 0
9191
>

src/utils/utils.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,19 @@ namespace detail {
165165
return value < 10 ? 1 : 1 + n_digits(value / 10);
166166
}
167167

168+
#if defined(__GNUC__) && (__GNUC__ < 5) && !defined(__clang__)
169+
template<typename T>
170+
using is_trivially_copyable = std::is_trivial<T>;
171+
#else
172+
template<typename T>
173+
using is_trivially_copyable = std::is_trivially_copyable<T>;
174+
#endif
175+
168176
// TODO: Re-evaluate use of off_t
169177
template<
170178
typename T,
171179
typename std::enable_if<
172-
std::is_standard_layout<T>::value && std::is_trivially_copyable<T>::value,
180+
std::is_standard_layout<T>::value && is_trivially_copyable<T>::value,
173181
int
174182
>::type = 0
175183
>
@@ -235,7 +243,7 @@ namespace detail {
235243
// <= 19.23 msvc also appears to fail (but for a different reason https://godbolt.org/z/6Y5EvdWPK)
236244
// <= 19.39 msvc also has trouble with it for different reasons https://godbolt.org/z/aPPPT7z3z
237245
typename std::enable_if<
238-
std::is_standard_layout<T>::value && std::is_trivially_copyable<T>::value,
246+
std::is_standard_layout<T>::value && is_trivially_copyable<T>::value,
239247
int
240248
>::type = 0,
241249
typename std::enable_if<

0 commit comments

Comments
 (0)