Add cpp_function_template
This commit is contained in:
parent
edb132981a
commit
93c6e0f44c
6 changed files with 71 additions and 0 deletions
|
|
@ -46,6 +46,7 @@ namespace cppast
|
|||
template_template_parameter_t,
|
||||
|
||||
alias_template_t,
|
||||
function_template_t,
|
||||
|
||||
count,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -112,6 +112,13 @@ namespace cppast
|
|||
return std::move(function);
|
||||
}
|
||||
|
||||
/// \returns The finished function without registering it.
|
||||
/// \notes This is intended for templated functions only.
|
||||
std::unique_ptr<T> finish()
|
||||
{
|
||||
return std::move(function);
|
||||
}
|
||||
|
||||
protected:
|
||||
basic_builder() = default;
|
||||
~basic_builder() noexcept = default;
|
||||
|
|
|
|||
42
include/cppast/cpp_function_template.hpp
Normal file
42
include/cppast/cpp_function_template.hpp
Normal 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_FUNCTION_TEMPLATE_HPP_INCLUDED
|
||||
#define CPPAST_CPP_FUNCTION_TEMPLATE_HPP_INCLUDED
|
||||
|
||||
#include <cppast/cpp_function.hpp>
|
||||
#include <cppast/cpp_template.hpp>
|
||||
|
||||
namespace cppast
|
||||
{
|
||||
/// A [cppast::cpp_entity]() modelling a function template.
|
||||
class cpp_function_template final : public cpp_template
|
||||
{
|
||||
public:
|
||||
/// Builder for [cppast::cpp_function_template]().
|
||||
class builder : public basic_builder<cpp_function_template, cpp_function_base>
|
||||
{
|
||||
public:
|
||||
using basic_builder::basic_builder;
|
||||
};
|
||||
|
||||
/// A reference to the function that is being templated.
|
||||
const cpp_function_base& function() const noexcept
|
||||
{
|
||||
return static_cast<const cpp_function_base&>(*begin());
|
||||
}
|
||||
|
||||
private:
|
||||
cpp_function_template(std::unique_ptr<cpp_function_base> func)
|
||||
: cpp_template(std::unique_ptr<cpp_entity>(func.release()))
|
||||
{
|
||||
}
|
||||
|
||||
cpp_entity_kind do_get_entity_kind() const noexcept override;
|
||||
|
||||
friend basic_builder<cpp_function_template, cpp_function_base>;
|
||||
};
|
||||
} // namespace cppast
|
||||
|
||||
#endif // CPPAST_CPP_FUNCTION_TEMPLATE_HPP_INCLUDED
|
||||
Loading…
Add table
Add a link
Reference in a new issue