Add cpp_variable_template

This commit is contained in:
Jonathan Müller 2017-02-05 22:03:57 +01:00
commit 78157d43fc
5 changed files with 64 additions and 0 deletions

View file

@ -46,6 +46,7 @@ namespace cppast
template_template_parameter_t,
alias_template_t,
variable_template_t,
function_template_t,
function_template_specialization_t,
class_template_t,

View file

@ -0,0 +1,42 @@
// Copyright (C) 2017 Jonathan Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
#ifndef CPPAST_CPP_VARIABLE_TEMPLATE_HPP_INCLUDED
#define CPPAST_CPP_VARIABLE_TEMPLATE_HPP_INCLUDED
#include <cppast/cpp_template.hpp>
#include <cppast/cpp_variable.hpp>
namespace cppast
{
/// A [cppast::cpp_entity]() modelling a C++ alias template.
class cpp_variable_template final : public cpp_template
{
public:
/// Builder for [cppast::cpp_variable_template]().
class builder : public basic_builder<cpp_variable_template, cpp_variable>
{
public:
using basic_builder::basic_builder;
};
/// \returns A reference to the type variable that is being templated.
const cpp_variable& variable() const noexcept
{
return static_cast<const cpp_variable&>(*begin());
}
private:
cpp_variable_template(std::unique_ptr<cpp_variable> variable)
: cpp_template(std::unique_ptr<cpp_entity>(variable.release()))
{
}
cpp_entity_kind do_get_entity_kind() const noexcept override;
friend basic_builder<cpp_variable_template, cpp_variable>;
};
} // namespace cppast
#endif // CPPAST_CPP_VARIABLE_TEMPLATE_HPP_INCLUDED

View file

@ -69,6 +69,8 @@ const char* cppast::to_string(cpp_entity_kind kind) noexcept
case cpp_entity_kind::alias_template_t:
return "alias template";
case cpp_entity_kind::variable_template_t:
return "variable template";
case cpp_entity_kind::function_template_t:
return "function template";
case cpp_entity_kind::function_template_specialization_t:
@ -116,6 +118,7 @@ bool cppast::is_type(cpp_entity_kind kind) noexcept
case cpp_entity_kind::non_type_template_parameter_t:
case cpp_entity_kind::template_template_parameter_t:
case cpp_entity_kind::alias_template_t:
case cpp_entity_kind::variable_template_t:
case cpp_entity_kind::function_template_t:
case cpp_entity_kind::function_template_specialization_t:
case cpp_entity_kind::class_template_t:
@ -132,6 +135,7 @@ bool cppast::is_template(cpp_entity_kind kind) noexcept
switch (kind)
{
case cpp_entity_kind::alias_template_t:
case cpp_entity_kind::variable_template_t:
case cpp_entity_kind::function_template_t:
case cpp_entity_kind::function_template_specialization_t:
case cpp_entity_kind::class_template_t:

View file

@ -0,0 +1,14 @@
// Copyright (C) 2017 Jonathan Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
#include <cppast/cpp_variable_template.hpp>
#include <cppast/cpp_entity_kind.hpp>
using namespace cppast;
cpp_entity_kind cpp_variable_template::do_get_entity_kind() const noexcept
{
return cpp_entity_kind::variable_template_t;
}

View file

@ -17,6 +17,7 @@
#include <cppast/cpp_member_function.hpp>
#include <cppast/cpp_namespace.hpp>
#include <cppast/cpp_template_parameter.hpp>
#include <cppast/cpp_variable_template.hpp>
using namespace cppast;
@ -65,6 +66,8 @@ bool detail::visit(const cpp_entity& e, detail::visitor_callback_t cb, void* fun
return handle_container<cpp_template_template_parameter>(e, cb, functor);
case cpp_entity_kind::alias_template_t:
return handle_container<cpp_alias_template>(e, cb, functor);
case cpp_entity_kind::variable_template_t:
return handle_container<cpp_variable_template>(e, cb, functor);
case cpp_entity_kind::function_template_t:
return handle_container<cpp_function_template>(e, cb, functor);
case cpp_entity_kind::function_template_specialization_t: