Skip to content

Commit

Permalink
Fix compilation with C++17 (#90)
Browse files Browse the repository at this point in the history
Replaced named struct initializer in list code to make the code C++17 compatible.

Explicit cast to ink::size_t in the generic string function.
  • Loading branch information
MrHands authored Oct 11, 2024
1 parent 8b85f2d commit 8210a41
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ Build/*
build/*
bin/
Bin/

# Visual Studio
/out/build/
/.vs
2 changes: 1 addition & 1 deletion inkcpp/include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class list_interface
};

/** access value the iterator is pointing to */
Flag operator*() const { return Flag{.flag_name = _flag_name, .list_name = _list_name}; };
Flag operator*() const { return Flag{ _flag_name, _list_name }; };

/** continue iterator to next value */
iterator& operator++()
Expand Down
30 changes: 15 additions & 15 deletions inkcpp/include/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,21 @@ template<typename T>
struct string_handler<T&> : string_handler<T> {
};

#define MARK_AS_STRING(TYPE, LEN, SRC) \
template<> \
struct is_string<TYPE> : constant<bool, true> { \
}; \
template<> \
struct string_handler<TYPE> { \
static size_t length(const TYPE& x) { return LEN; } \
static void src_copy(const TYPE& x, char* output) \
{ \
[&output](const char* src) { \
while (*src != '\0') \
*(output++) = *(src++); \
*output = 0; \
}(SRC); \
} \
#define MARK_AS_STRING(TYPE, LEN, SRC) \
template<> \
struct is_string<TYPE> : constant<bool, true> { \
}; \
template<> \
struct string_handler<TYPE> { \
static size_t length(const TYPE& x) { return static_cast<size_t>(LEN); } \
static void src_copy(const TYPE& x, char* output) \
{ \
[&output](const char* src) { \
while (*src != '\0') \
*(output++) = *(src++); \
*output = 0; \
}(SRC); \
} \
}

inline size_t c_str_len(const char* c)
Expand Down

0 comments on commit 8210a41

Please sign in to comment.