Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore legacy C++ implementations #492

Merged
merged 3 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,51 @@ cc_test(
],
)

cc_library(
name = "indirect_cxx14",
hdrs = [
"indirect.h",
"indirect_cxx14.h",
],
copts = ["-Iexternal/value_types/"],
defines = ["XYZ_INDIRECT_CXX_14"],
visibility = ["//visibility:public"],
)

cc_test(
name = "indirect_cxx14_test",
size = "small",
srcs = [
"indirect_test.cc",
],
copts = ["-std=c++14"],
deps = [
"feature_check",
"indirect_cxx14",
"tagged_allocator",
"test_helpers",
"tracking_allocator",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "indirect_cxx17_test",
size = "small",
srcs = [
"indirect_test.cc",
],
copts = ["-std=c++17"],
deps = [
"feature_check",
"indirect_cxx14",
"tagged_allocator",
"test_helpers",
"tracking_allocator",
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "polymorphic",
hdrs = ["polymorphic.h"],
Expand All @@ -65,3 +110,45 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "polymorphic_cxx14",
hdrs = ["polymorphic_cxx14.h"],
copts = ["-Iexternal/value_types/"],
defines = ["XYZ_POLYMORPHIC_CXX_14"],
visibility = ["//visibility:public"],
)

cc_test(
name = "polymorphic_cxx14_test",
size = "small",
srcs = [
"polymorphic_test.cc",
],
copts = ["-std=c++14"],
deps = [
"feature_check",
"polymorphic_cxx14",
"tagged_allocator",
"test_helpers",
"tracking_allocator",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "polymorphic_cxx17_test",
size = "small",
srcs = [
"polymorphic_test.cc",
],
copts = ["-std=c++17"],
deps = [
"feature_check",
"polymorphic_cxx14",
"tagged_allocator",
"test_helpers",
"tracking_allocator",
"@com_google_googletest//:gtest_main",
],
)
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,40 @@ if (${XYZ_VALUE_TYPES_IS_NOT_SUBPROJECT})
FILES indirect_test.cc
)

xyz_add_test(
NAME indirect_cxx14_test
LINK_LIBRARIES indirect_cxx14
FILES indirect_test.cc
VERSION 14
)

xyz_add_test(
NAME indirect_cxx17_test
LINK_LIBRARIES indirect_cxx17
FILES indirect_test.cc
VERSION 17
)

xyz_add_test(
NAME polymorphic_test
LINK_LIBRARIES polymorphic
FILES polymorphic_test.cc
)

xyz_add_test(
NAME polymorphic_cxx14_test
LINK_LIBRARIES polymorphic_cxx14
FILES polymorphic_test.cc
VERSION 14
)

xyz_add_test(
NAME polymorphic_cxx17_test
LINK_LIBRARIES polymorphic_cxx17
FILES polymorphic_test.cc
VERSION 17
)

if (ENABLE_CODE_COVERAGE)
enable_code_coverage()
endif()
Expand Down
44 changes: 44 additions & 0 deletions feature_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,50 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef XYZ_FEATURE_CHECK_H
#define XYZ_FEATURE_CHECK_H

// The purpose of this header is to provide macros checking whether certain C++
// features (like std::optional) are available.

//
// XYZ_HAS_STD_OPTIONAL
// The macro is defined, when std::optional is available.
//
#ifdef XYZ_HAS_STD_OPTIONAL
#error "XYZ_HAS_STD_OPTIONAL is already defined"
#endif // XYZ_HAS_STD_OPTIONAL

#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
#define XYZ_HAS_STD_OPTIONAL
#endif //(__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >=
// 201703L)

//
// XYZ_HAS_STD_IN_PLACE_TYPE_T
// The macro is defined, when std::in_place_type_t is available.
//

#ifdef XYZ_HAS_STD_IN_PLACE_TYPE_T
#error "XYZ_HAS_STD_IN_PLACE_TYPE_T is already defined"
#endif // XYZ_HAS_STD_IN_PLACE_TYPE_T

#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
#define XYZ_HAS_STD_IN_PLACE_TYPE_T
#endif //(__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >=
// 201703L)

#ifdef XYZ_HAS_STD_IN_PLACE_T
#error "XYZ_HAS_STD_IN_PLACE_T is already defined"
#endif // XYZ_HAS_STD_IN_PLACE_T

#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
#define XYZ_HAS_STD_IN_PLACE_T
#endif //(__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >=
// 201703L)

#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
#define XYZ_HAS_TEMPLATE_ARGUMENT_DEDUCTION
#endif //(__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >=
// 201703L)

//
// XYZ_HAS_STD_MEMORY_RESOURCE
// The macro is defined, when the header <memory_resource> and its content is
Expand Down
Loading
Loading