From bd7fd8e104fed054dcd3b9b4ad0e97008be0e04e Mon Sep 17 00:00:00 2001 From: Ashton Meuser Date: Sat, 1 Jun 2024 09:10:39 -0700 Subject: [PATCH] Avoid use of C++17 constexpr --- src/string-container.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/string-container.h b/src/string-container.h index 4177372..10ae205 100644 --- a/src/string-container.h +++ b/src/string-container.h @@ -12,15 +12,20 @@ Required because List does not support subscript operator, GDExtension PackedStr #include "defs.h" namespace { - template struct has_subscript_operator: std::false_type {}; - template struct has_subscript_operator()[std::declval()])>>: std::true_type {}; + template struct has_subscript_operator: std::false_type {}; + template struct has_subscript_operator()[std::declval()])>>: std::true_type {}; + template struct has_get_method: std::false_type {}; + template struct has_get_method().get(std::declval()))>>: std::true_type {}; } -namespace godot{ - template String string_container_get(T container, const int i) { - if constexpr (has_subscript_operator::value) return container[i]; - else return container.get(i); - } +namespace godot { + template typename std::enable_if::value, String>::type string_container_get(T container, const uint32_t i) { + return container[i]; + } + + template typename std::enable_if::value && !has_subscript_operator::value, String>::type string_container_get(T container, const uint32_t i) { + return container.get(i); + } } #endif \ No newline at end of file