From 8210a4163ccf33321ba602a4f12cde274ce0ca40 Mon Sep 17 00:00:00 2001 From: "Mr. Hands" Date: Fri, 11 Oct 2024 08:47:49 +0200 Subject: [PATCH] Fix compilation with C++17 (#90) 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. --- .gitignore | 4 ++++ inkcpp/include/list.h | 2 +- inkcpp/include/traits.h | 30 +++++++++++++++--------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 8921e3a5..8d3e9b58 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ Build/* build/* bin/ Bin/ + +# Visual Studio +/out/build/ +/.vs diff --git a/inkcpp/include/list.h b/inkcpp/include/list.h index 4db814e1..c28d8471 100644 --- a/inkcpp/include/list.h +++ b/inkcpp/include/list.h @@ -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++() diff --git a/inkcpp/include/traits.h b/inkcpp/include/traits.h index 4902399d..fea68002 100644 --- a/inkcpp/include/traits.h +++ b/inkcpp/include/traits.h @@ -140,21 +140,21 @@ template struct string_handler : string_handler { }; -#define MARK_AS_STRING(TYPE, LEN, SRC) \ - template<> \ - struct is_string : constant { \ - }; \ - template<> \ - struct string_handler { \ - 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 : constant { \ + }; \ + template<> \ + struct string_handler { \ + static size_t length(const TYPE& x) { return static_cast(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)