diff --git a/include/cppast/cpp_alias_template.hpp b/include/cppast/cpp_alias_template.hpp index 2cdd216..06fad40 100644 --- a/include/cppast/cpp_alias_template.hpp +++ b/include/cppast/cpp_alias_template.hpp @@ -28,12 +28,14 @@ namespace cppast } private: - cpp_alias_template(std::string name, std::unique_ptr alias) - : cpp_template(std::move(name), std::unique_ptr(alias.release())) + cpp_alias_template(std::unique_ptr alias) + : cpp_template(std::unique_ptr(alias.release())) { } cpp_entity_kind do_get_entity_kind() const noexcept override; + + friend basic_builder; }; } // namespace cppast diff --git a/include/cppast/cpp_template.hpp b/include/cppast/cpp_template.hpp index 7152d82..a7534ff 100644 --- a/include/cppast/cpp_template.hpp +++ b/include/cppast/cpp_template.hpp @@ -33,8 +33,7 @@ namespace cppast { public: /// \effects Sets the name and the entity that is begin templated. - basic_builder(std::string name, std::unique_ptr templ) - : template_entity(new T(name, std::move(templ))) + basic_builder(std::unique_ptr templ) : template_entity(new T(std::move(templ))) { } @@ -62,8 +61,7 @@ namespace cppast /// \effects Sets the name of the template and the entity to be templated. /// \notes It does not include the parameters. - cpp_template(std::string name, std::unique_ptr entity) - : cpp_entity(std::move(name)) + cpp_template(std::unique_ptr entity) : cpp_entity(entity->name()) { add_child(std::move(entity)); } diff --git a/include/cppast/cpp_type_alias.hpp b/include/cppast/cpp_type_alias.hpp index b40ec4a..7b67ff3 100644 --- a/include/cppast/cpp_type_alias.hpp +++ b/include/cppast/cpp_type_alias.hpp @@ -20,6 +20,11 @@ namespace cppast std::string name, std::unique_ptr type); + /// \returns A newly created type alias that isn't registered. + /// \notes This function is intendend for templated type aliases. + static std::unique_ptr build(std::string name, + std::unique_ptr type); + /// \returns A reference to the aliased [cppast::cpp_type](). const cpp_type& underlying_type() const noexcept { diff --git a/src/cpp_type_alias.cpp b/src/cpp_type_alias.cpp index e6dd628..360c34f 100644 --- a/src/cpp_type_alias.cpp +++ b/src/cpp_type_alias.cpp @@ -12,12 +12,17 @@ std::unique_ptr cpp_type_alias::build(const cpp_entity_index& id std::string name, std::unique_ptr type) { - auto result = - std::unique_ptr(new cpp_type_alias(std::move(name), std::move(type))); + auto result = build(std::move(name), std::move(type)); idx.register_entity(std::move(id), type_safe::cref(*result)); return result; } +std::unique_ptr cpp_type_alias::build(std::string name, + std::unique_ptr type) +{ + return std::unique_ptr(new cpp_type_alias(std::move(name), std::move(type))); +} + cpp_entity_kind cpp_type_alias::do_get_entity_kind() const noexcept { return cpp_entity_kind::type_alias_t;