-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dan Smith
committed
Jan 10, 2022
1 parent
28ab350
commit 26ba1a9
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
externals/coda-oss/modules/c++/std/include/std/type_traits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* ========================================================================= | ||
* This file is part of std-c++ | ||
* ========================================================================= | ||
* | ||
* (C) Copyright 2022, Maxar Technologies, Inc. | ||
* | ||
* sys-c++ is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this program; If not, http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
#ifndef CODA_OSS_std_type_traits_INCLUDED_ | ||
#define CODA_OSS_std_type_traits_INCLUDED_ | ||
#pragma once | ||
|
||
// Make it (too?) easy for clients to get our various std:: implementations | ||
#include "sys/TypeTraits.h" | ||
|
||
#ifndef CODA_OSS_NO_is_trivially_copyable | ||
#define CODA_OSS_NO_is_trivially_copyable 0 // enabled, unless explicitly disabled | ||
#endif | ||
|
||
#if !CODA_OSS_NO_is_trivially_copyable | ||
// https://stackoverflow.com/a/31798726/8877 | ||
// workaround missing "is_trivially_copyable" in g++ < 5.0 | ||
#if defined(__GNUC__) && (__GNUC__ < 5) | ||
namespace std // This is slightly uncouth: we're not supposed to augment "std". | ||
{ | ||
template <class T> | ||
using is_trivially_copyable = sys::IsTriviallyCopyable<T>; | ||
} | ||
#endif // __GNUC__ | ||
#endif // CODA_OSS_NO_is_trivially_copyable | ||
|
||
#endif // CODA_OSS_std_type_traits_INCLUDED_ | ||
|
46 changes: 46 additions & 0 deletions
46
externals/coda-oss/modules/c++/sys/include/sys/TypeTraits.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* ========================================================================= | ||
* This file is part of sys-c++ | ||
* ========================================================================= | ||
* | ||
* (C) Copyright 2022, Maxar Technologies, Inc. | ||
* | ||
* sys-c++ is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this program; If not, http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
#ifndef CODA_OSS_sys_TypeTraits_h_INCLUDED_ | ||
#define CODA_OSS_sys_TypeTraits_h_INCLUDED_ | ||
#pragma once | ||
|
||
#include <type_traits> | ||
|
||
#include "CPlusPlus.h" | ||
|
||
namespace sys | ||
{ | ||
template <class T> | ||
// workaround missing "is_trivially_copyable" in g++ < 5.0 | ||
#if defined(__GNUC__) && (__GNUC__ < 5) | ||
static_assert(CODA_OSS_cplusplus < 201402L, "C++14 must have is_trivially_copyable."); | ||
struct IsTriviallyCopyable final | ||
{ | ||
// https://stackoverflow.com/a/31798726/8877 | ||
static constexpr bool value = __has_trivial_copy(T); | ||
}; | ||
#else | ||
template <typename T> | ||
using IsTriviallyCopyable = std::is_trivially_copyable<T>; | ||
#endif | ||
} | ||
|
||
#endif // CODA_OSS_sys_TypeTraits_h_INCLUDED_ |