Added initial support for C++20 concepts
This commit is contained in:
@@ -79,6 +79,9 @@ public:
|
||||
|
||||
bool is_abstract() const;
|
||||
|
||||
bool is_concept() const { return is_concept_; }
|
||||
void is_concept(bool concept_) { is_concept_ = concept_; }
|
||||
|
||||
void find_relationships(
|
||||
std::vector<std::pair<std::string, common::model::relationship_t>>
|
||||
&nested_relationships);
|
||||
@@ -92,6 +95,7 @@ private:
|
||||
bool is_template_instantiation_{false};
|
||||
bool is_alias_{false};
|
||||
bool is_union_{false};
|
||||
bool is_concept_{false};
|
||||
std::vector<class_member> members_;
|
||||
std::vector<class_method> methods_;
|
||||
std::vector<class_parent> bases_;
|
||||
|
||||
@@ -83,6 +83,13 @@ public:
|
||||
|
||||
virtual bool VisitTypeAliasTemplateDecl(clang::TypeAliasTemplateDecl *cls);
|
||||
|
||||
// bool TraverseTypeConstraint(const clang::TypeConstraint *C);
|
||||
// bool TraverseConceptRequirement(clang::concepts::Requirement *R);
|
||||
// bool TraverseConceptTypeRequirement(clang::concepts::TypeRequirement *R);
|
||||
// bool TraverseConceptExprRequirement(clang::concepts::ExprRequirement *R);
|
||||
// bool TraverseConceptNestedRequirement(
|
||||
// clang::concepts::NestedRequirement *R);
|
||||
|
||||
/**
|
||||
* @brief Get diagram model reference
|
||||
*
|
||||
|
||||
@@ -1,10 +1,57 @@
|
||||
#include <string>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t00056 {
|
||||
// Constraint expression
|
||||
template <typename T>
|
||||
concept MaxFourBytes = sizeof(T) <= 4;
|
||||
|
||||
// Simple requirement
|
||||
template <typename T>
|
||||
concept Iterable = requires(T container) {
|
||||
container.begin();
|
||||
container.end();
|
||||
};
|
||||
|
||||
// Type requirement
|
||||
template <typename T>
|
||||
concept HasValueType = requires { typename T::value_type; };
|
||||
|
||||
template <typename T>
|
||||
concept ConvertibleToString = requires(T s) { std::string{s}; };
|
||||
|
||||
// Compound requirement
|
||||
// ...
|
||||
|
||||
// Combined concept
|
||||
template <typename T>
|
||||
concept IterableWithValueType = Iterable<T> && HasValueType<T>;
|
||||
|
||||
template <typename T>
|
||||
concept IterableWithSmallValueType =
|
||||
IterableWithValueType<T> && MaxFourBytes<T>;
|
||||
|
||||
// Simple type constraint
|
||||
template <MaxFourBytes T> struct A {
|
||||
T a;
|
||||
};
|
||||
|
||||
// Requires constant expression
|
||||
template <typename T>
|
||||
requires MaxFourBytes<T>
|
||||
struct B {
|
||||
T b;
|
||||
};
|
||||
|
||||
// Anonymous concept requirement
|
||||
template <typename T>
|
||||
requires requires(T t) {
|
||||
--t;
|
||||
t--;
|
||||
}
|
||||
struct C {
|
||||
T c;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user