Skip to content

Commit

Permalink
fix windows bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
i-curve committed Dec 19, 2023
1 parent 781d594 commit ae1b391
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 24 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.vscode/*
.idea
.vs

build/*
data.h

cmake-build-debug
cmake-build-release
out
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.10)

project(copypp VERSION 0.2.0 LANGUAGES CXX)
project(copypp VERSION 0.3.0 LANGUAGES CXX)

# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_CXX_STANDARD 20)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ std::array<BB, 2> b = {BB(1, "first", true), BB(2, "second", false)};
icurve::copy(a, b);
```

stl support
### stl support

copypp support stl copy, condition:

Expand Down
5 changes: 2 additions & 3 deletions include/icurve/copypp.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#if (_MSC_VER && _MSVC_LANG < 202002L) || __cplusplus < 202002L
#if (_MSC_VER && _MSVC_LANG < 202002L) || (!_MSC_VER && __cplusplus < 202002L)
#error "minimun c++ version is c++20."
#endif

Expand All @@ -15,7 +15,6 @@
#endif

namespace icurve {

class _copypp_raw_meta {
public:
std::string field_type = "";
Expand Down Expand Up @@ -79,7 +78,7 @@ requires requires(D d, S s) {
std::ranges::end(d);
}
void copy(D &destination, S &source) {
for (auto dp = destination.begin(), sp = source.begin();
for (auto [dp, sp] = std::make_tuple(destination.begin(), source.begin());
dp != destination.end() && sp != source.end(); ++dp, ++sp) {
icurve::copy(*dp, *sp);
}
Expand Down
8 changes: 2 additions & 6 deletions include/icurve/copypp_only.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#if (_MSC_VER && _MSVC_LANG < 202002L) || __cplusplus < 202002L
#if (_MSC_VER && _MSVC_LANG < 202002L) || (!_MSC_VER && __cplusplus < 202002L)
#error "minimun c++ version is c++20."
#endif

Expand All @@ -13,7 +13,6 @@
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(...)
#endif


#define _COPYPP_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
#define _COPYPP_EXPAND(x) x

Expand Down Expand Up @@ -151,7 +150,6 @@
_COPYPP_PASTE0)(__VA_ARGS__)) \
//


#define _COPYPP_EXPANG_DATA(v) this->_data.push_back(icurve::_copypp_raw_meta(typeid(v).name(), #v, sizeof(v), &v));

#define _COPYPP_PREPARE0()
Expand Down Expand Up @@ -364,7 +362,6 @@
#define _COPYPP_SETFIELD63(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) _COPYPP_EXPANG_SETFIELD(v1) _COPYPP_SETFIELD62(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
#define _COPYPP_SETFIELD64(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63, v64) _COPYPP_EXPANG_SETFIELD(v1) _COPYPP_SETFIELD63(v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63, v64)


#define _COPYPP_META_SETFIELD(...) \
void _setField(std::string name, void *val) { \
if (val == nullptr) { return; } \
Expand Down Expand Up @@ -438,7 +435,6 @@
//

namespace icurve {

class _copypp_raw_meta {
public:
std::string field_type = "";
Expand Down Expand Up @@ -501,7 +497,7 @@ requires requires(D d, S s) {
std::ranges::end(d);
}
void copy(D &destination, S &source) {
for (auto dp = destination.begin(), sp = source.begin();
for (auto [dp,sp] = std::make_tuple(destination.begin(), source.begin());
dp != destination.end() && sp != source.end(); ++dp, ++sp) {
icurve::copy(*dp, *sp);
}
Expand Down
5 changes: 3 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# find_package
find_package(GTest CONFIG REQUIRED)
find_package(fmt)
find_package(nlohmann_json CONFIG REQUIRED)
set(CMAKE_CXX_STANDARD 20)
Expand All @@ -7,12 +8,12 @@ message(STATUS "test")
include_directories(${PROJECT_SOURCE_DIR}/include)

add_executable(copypp_test copypp_test.cpp)
target_link_libraries(copypp_test PRIVATE fmt::fmt-header-only)
target_link_libraries(copypp_test PRIVATE fmt::fmt-header-only GTest::gtest GTest::gtest_main)
target_link_directories(copypp_test PUBLIC ${PROJECT_SOURCE_DIR}/include)
add_test(NAME copypp_test COMMAND copypp_test)

add_executable(copypp_test2 copypp_test2.cpp)
target_link_libraries(copypp_test2 PRIVATE fmt::fmt-header-only)
target_link_libraries(copypp_test2 PRIVATE fmt::fmt-header-only GTest::gtest GTest::gtest_main)
target_link_directories(copypp_test2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
add_test(NAME copypp_test2 COMMAND copypp_test2)

Expand Down
1 change: 1 addition & 0 deletions test/copypp_only_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <fmt/core.h>
#include <cassert>
#include <list>
#include <array>
#include <icurve/copypp_only.hh>
#include <gtest/gtest.h>

Expand Down
4 changes: 2 additions & 2 deletions test/copypp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#include <fmt/core.h>
#include <cassert>
#include <gtest/gtest.h>
#include "icurve/copypp.hh"
#include "A.h"
#include "B.h"
Expand Down Expand Up @@ -33,13 +34,12 @@ void checkaa() {
}

// COPYPP
int main() {
TEST(COPYPP_TEST1, _1) {
fmt::println("copypp test...");
A a(1, "curve", true);
B b;
icurve::copy(b, a);
check(b, a);

checkaa();
return 0;
}
12 changes: 3 additions & 9 deletions test/copypp_test2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#include <fmt/core.h>
#include <cassert>
#include <gtest/gtest.h>
#include "icurve/copypp.hh"
#include "A.h"
#include "B.h"
Expand All @@ -14,21 +15,14 @@ void check();
void check1();
void check2();

int main() {
fmt::println("copypp test2...");
check1();
check2();
return 0;
}

void check(BB &b, AA &a) {
assert(a.getId() == b.getId());
fmt::println("a.name: {}, b.name: {}", a.getName(), b.getName());
assert(a.getName() == b.getName());
assert(a.getSex() == b.getSex());
}

void check1() {
TEST(COPYPP_TEST2, _1) {
fmt::println("check1:");
AA a(10, "curve", false);
a._prepareFields();
Expand All @@ -38,7 +32,7 @@ void check1() {
}
}

void check2() {
TEST(COPYPP_TEST2, _2) {
AA a(10, "curve", true);
BB b;
icurve::copy(b, a);
Expand Down

0 comments on commit ae1b391

Please sign in to comment.