diff --git a/include/xo/reflect/function/FunctionTdx.hpp b/include/xo/reflect/function/FunctionTdx.hpp index 116f372..5d2f57c 100644 --- a/include/xo/reflect/function/FunctionTdx.hpp +++ b/include/xo/reflect/function/FunctionTdx.hpp @@ -24,6 +24,10 @@ namespace xo { static std::unique_ptr make_function(TypeDescr retval_td, std::vector arg_td_v, bool is_noexcept); + /** create instance from FunctionTdxInfo + * @param fn_info. function ingredients -- return type, arg types, noexcept + **/ + static std::unique_ptr make_function(const FunctionTdxInfo & fn_info); // ----- Inherited from TypeDescrExtra ----- @@ -39,9 +43,7 @@ namespace xo { virtual bool fn_is_noexcept() const override { return info_.is_noexcept_; } private: - FunctionTdx(TypeDescr retval_td, - bool is_noexcept, - std::vector arg_td_v); + FunctionTdx(const FunctionTdxInfo & fn_info); private: /** ingredients in complete function type description **/ diff --git a/src/reflect/function/FunctionTdx.cpp b/src/reflect/function/FunctionTdx.cpp index c81041a..27c0f8f 100644 --- a/src/reflect/function/FunctionTdx.cpp +++ b/src/reflect/function/FunctionTdx.cpp @@ -11,17 +11,21 @@ namespace xo { std::vector arg_td_v, bool is_noexcept) { - return std::unique_ptr(new FunctionTdx(retval_td, - is_noexcept, - std::move(arg_td_v))); + return make_function(FunctionTdxInfo(retval_td, + std::move(arg_td_v), + is_noexcept)); } - FunctionTdx::FunctionTdx(TypeDescr retval_td, - bool is_noexcept, - std::vector arg_td_v) - : info_{retval_td, std::move(arg_td_v), is_noexcept} + std::unique_ptr + FunctionTdx::make_function(const FunctionTdxInfo & fn_info) { - if (!retval_td) { + return std::unique_ptr(new FunctionTdx(fn_info)); + } + + FunctionTdx::FunctionTdx(const FunctionTdxInfo & fn_info) + : info_{fn_info} + { + if (!info_.retval_td_) { throw std::runtime_error("FunctionTdx::ctor: null return type?"); } }