Skip to content

Commit

Permalink
remove pre-C++20 work-arounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Jan 25, 2024
1 parent 0a4c27d commit c3540fd
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 86 deletions.
38 changes: 1 addition & 37 deletions modules/c++/coda_oss/include/coda_oss/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,11 @@
*/

#pragma once
#ifndef CODA_OSS_coda_oss_string_h_INCLUDED_
#define CODA_OSS_coda_oss_string_h_INCLUDED_

#include <string>

#include "coda_oss/CPlusPlus.h"

// This logic needs to be here rather than <std/string> so that `coda_oss::u8string` will
// be the same as `std::u8string`.
#ifndef CODA_OSS_HAVE_std_u8string_
#define CODA_OSS_HAVE_std_u8string_ 0 // assume no std::u8string
#endif
#if CODA_OSS_cpp20
#if defined(__cpp_lib_char8_t) // https://en.cppreference.com/w/cpp/feature_test
#undef CODA_OSS_HAVE_std_u8string_
#define CODA_OSS_HAVE_std_u8string_ 1
#endif
#endif // CODA_OSS_cpp20

#include "config/compiler_extensions.h"

namespace coda_oss
{
// char8_t for UTF-8 characters
CODA_OSS_disable_warning_push
#if _MSC_VER
#pragma warning(disable: 5052) // Keyword '...' was introduced in C++20 and requires use of the '...' command-line option
#endif

#if !defined(__cpp_char8_t) // https://en.cppreference.com/w/cpp/feature_test
enum class char8_t : unsigned char { }; // https://en.cppreference.com/w/cpp/language/types
#elif CODA_OSS_HAVE_std_u8string_
// `char8_t` is a keyword in C++20
#endif
#if CODA_OSS_HAVE_std_u8string_
using u8string = std::u8string;
#else
using u8string = std::basic_string<char8_t>; // https://en.cppreference.com/w/cpp/string
#endif

CODA_OSS_disable_warning_pop
using std::u8string;
}

#endif // CODA_OSS_coda_oss_string_h_INCLUDED_
6 changes: 1 addition & 5 deletions modules/c++/std/include/std/cstddef
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@
*
*/
#pragma once
#ifndef CODA_OSS_std_cstddef_INCLUDED_
#define CODA_OSS_std_cstddef_INCLUDED_

#include <cstddef>

#endif // CODA_OSS_std_cstddef_INCLUDED_
#include "coda_oss/cstddef.h"
4 changes: 0 additions & 4 deletions modules/c++/std/include/std/filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
*
*/
#pragma once
#ifndef CODA_OSS_std_filesystem_INCLUDED_
#define CODA_OSS_std_filesystem_INCLUDED_

#include <filesystem>
#include "sys/filesystem.h"

#endif // CODA_OSS_std_filesystem_INCLUDED_
4 changes: 0 additions & 4 deletions modules/c++/std/include/std/memory
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@
*
*/
#pragma once
#ifndef CODA_OSS_std_memory_INCLUDED_
#define CODA_OSS_std_memory_INCLUDED_

#include <memory>

#endif // CODA_OSS_std_memory_INCLUDED_
3 changes: 0 additions & 3 deletions modules/c++/std/include/std/optional
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
*
*/
#pragma once
#ifndef CODA_OSS_std_optional_INCLUDED_
#define CODA_OSS_std_optional_INCLUDED_

#include "coda_oss/optional.h"

#endif // CODA_OSS_std_optional_INCLUDED_
29 changes: 0 additions & 29 deletions modules/c++/std/include/std/string
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,5 @@
*
*/
#pragma once
#ifndef CODA_OSS_std_string_INCLUDED_
#define CODA_OSS_std_string_INCLUDED_

#include <string>
#include "coda_oss/string.h"

// Make it (too?) easy for clients to get our various std:: implementations
#ifndef CODA_OSS_NO_std_u8string
#if CODA_OSS_HAVE_std_u8string_ // set in coda_oss/string.h
#define CODA_OSS_NO_std_u8string 1 // no need to muck with `std`
#else
#define CODA_OSS_NO_std_u8string 0 // use our own
#endif
#endif

#if !CODA_OSS_NO_std_u8string
#include "config/compiler_extensions.h"
namespace std // This is slightly uncouth: we're not supposed to augment "std".
{
CODA_OSS_disable_warning_push
#if defined(_MSC_VER) && (_MSC_VER >= 1927)
#pragma warning(disable: 5052) // Keyword '...' was introduced in C++ 20 and requires use of the '...' command-line option
#endif
using char8_t = coda_oss::char8_t;
CODA_OSS_disable_warning_pop

using coda_oss::u8string;
}
#endif // !CODA_OSS_NO_std_u8string

#endif // CODA_OSS_std_string_INCLUDED_
5 changes: 1 addition & 4 deletions modules/c++/std/include/std/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
*
*/
#pragma once
#ifndef CODA_OSS_std_type_traits_INCLUDED_
#define CODA_OSS_std_type_traits_INCLUDED_

#include <type_traits>
#include "coda_oss/type_traits.h"

#endif // CODA_OSS_std_type_traits_INCLUDED_

0 comments on commit c3540fd

Please sign in to comment.