diff --git a/cpp/Platform.Interfaces/IArray.h b/cpp/Platform.Interfaces/IArray.h index d362f3c1..350cc201 100644 --- a/cpp/Platform.Interfaces/IArray.h +++ b/cpp/Platform.Interfaces/IArray.h @@ -5,16 +5,21 @@ namespace Platform::Interfaces template consteval bool IArrayHelpFunction() { + constexpr bool member_indexator = requires(Self self, std::size_t index) + { + { self[index] } -> std::same_as::ItemReference>; + }; + if constexpr (sizeof...(Items) == 1) { using SelfItem = typename Enumerable::Item; using RequiredItem = std::remove_reference_t(std::declval>()))>; - return std::ranges::random_access_range && std::same_as; + return member_indexator && std::ranges::random_access_range && std::same_as; } if constexpr (sizeof...(Items) == 0) { - return std::ranges::random_access_range; + return member_indexator && std::ranges::random_access_range; } return false; diff --git a/cpp/Platform.Interfaces/IDictionary.h b/cpp/Platform.Interfaces/IDictionary.h index 0f6ac841..fbf0730f 100644 --- a/cpp/Platform.Interfaces/IDictionary.h +++ b/cpp/Platform.Interfaces/IDictionary.h @@ -2,19 +2,24 @@ namespace Platform::Interfaces { namespace Internal { - template + template consteval bool IDictionaryHelpFunction() { + using Self = std::remove_const_t; + + using GenericKey = std::remove_reference_t(std::declval::Item>()))>; + using GenericValue = std::remove_reference_t(std::declval::Item>()))>; + if constexpr (sizeof...(Args) == 0) { return requires ( Self self, - decltype(std::declval::Item>().first) generic_key, - decltype(std::declval::Item>().second) generic_value + GenericKey generic_key, + GenericValue generic_value ) { - { self[generic_key] } -> std::same_as::ItemReference>; + { self[generic_key] } -> std::same_as; { self.find(generic_key) } -> std::forward_iterator; { self.contains(generic_key) } -> std::same_as; { self.insert({generic_key, generic_value}) }; @@ -36,7 +41,7 @@ namespace Platform::Interfaces decltype(std::declval::Item>().second) generic_value ) { - { self[key] } -> std::same_as::ItemReference>; + { self[key] } -> std::same_as; { self.find(key) } -> std::forward_iterator; { self.contains(key) } -> std::same_as; { self.insert({key, generic_value}) }; @@ -58,7 +63,7 @@ namespace Platform::Interfaces decltype(std::get<1>(args)) value ) { - { self[key] } -> std::same_as::ItemReference>; + { self[key] } -> std::same_as; { self.find(key) } -> std::forward_iterator; { self.contains(key) } -> std::same_as; { self.insert({key, value}) }; diff --git a/cpp/Platform.Interfaces/IList.h b/cpp/Platform.Interfaces/IList.h index 02155e56..395f1dae 100644 --- a/cpp/Platform.Interfaces/IList.h +++ b/cpp/Platform.Interfaces/IList.h @@ -2,9 +2,11 @@ namespace Platform::Interfaces { namespace Internal { - template + template consteval bool IListHelpFunction() { + using Self = std::remove_const_t; + if constexpr (sizeof...(Item) == 1) { return requires @@ -16,7 +18,6 @@ namespace Platform::Interfaces std::ranges::iterator_t const_iterator ) { - { self[index] } -> std::same_as::ItemReference>; { self.push_back(item) }; { self.insert(const_iterator, item) }; { self.erase(const_iterator) }; @@ -34,7 +35,6 @@ namespace Platform::Interfaces typename Enumerable::Iter const_iterator ) { - { self[index] } -> std::same_as::ItemReference>; { self.push_back(generic_item) }; { self.insert(const_iterator, generic_item) }; { self.erase(const_iterator) }; diff --git a/cpp/Platform.Interfaces/ISet.h b/cpp/Platform.Interfaces/ISet.h index f93cae53..7b960909 100644 --- a/cpp/Platform.Interfaces/ISet.h +++ b/cpp/Platform.Interfaces/ISet.h @@ -2,9 +2,11 @@ namespace Platform::Interfaces { namespace Internal { - template + template consteval bool ISetHelpFunction() { + using Self = std::remove_const_t; + if constexpr (sizeof...(Items) == 1) { return requires diff --git a/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.nuspec b/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.nuspec index bdc87066..9aee50b4 100644 --- a/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.nuspec +++ b/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.nuspec @@ -6,13 +6,12 @@ LinksPlatform's Platform.Interfaces is a Template Library what contains common concepts templates. LinksPlatform's Platform.Interfaces is a Template Library what contains set of C++ concepts templates. Use Platform.Interfaces.h file to include the library. - Fixed compile-error bug => (concepts without Item type tried get first type from Items... set) - Added more concepts: - - Added IDictionary concept (std::map and other dictionary types) - - Added ISet concept (std::set and other set types) - Moved concepts logic to Internal ConceptHelpFunction +Bug fixes: + - IAray now has operator[] + - IDictionary fix operator[] + - readonly collections are still equal to the usual ones - 0.1.2 + 0.1.3 Konstantin Diachenko Konstantin Diachenko Konstantin Diachenko diff --git a/cpp/Platform.Interfaces/Platform.Interfaces.h b/cpp/Platform.Interfaces/Platform.Interfaces.h index 2862a322..1d342fc0 100644 --- a/cpp/Platform.Interfaces/Platform.Interfaces.h +++ b/cpp/Platform.Interfaces/Platform.Interfaces.h @@ -4,6 +4,7 @@ #define PLATFORM_INTERFACES #include +#include #include "IEnumerable.h" #include "IArray.h"