MCPcopy Create free account
hub / github.com/andreasfertig/cppinsights / EvaluateNTTPAsConstantExpr

Function EvaluateNTTPAsConstantExpr

CodeGenerator.cpp:1767–1779  ·  view source on GitHub ↗

\brief Evaluates a potential NTTP as a constant expression. Used for C++20's struct/class as NTTP.

Source from the content-addressed store, hash-verified

1765///
1766/// Used for C++20's struct/class as NTTP.
1767static std::optional<std::pair<QualType, APValue>> EvaluateNTTPAsConstantExpr(const Expr* expr)
1768{
1769 expr = expr->IgnoreParenImpCasts();
1770
1771 // The marker when it is a C++20 class as NTTP seems to be CXXFunctionalCastExpr
1772 if(Expr::EvalResult evalResult{};
1773 isa<CXXFunctionalCastExpr>(expr) and
1774 expr->EvaluateAsConstantExpr(evalResult, GetGlobalAST(), ConstantExprKind::Normal)) {
1775 return std::pair<QualType, APValue>{expr->getType(), evalResult.Val};
1776 }
1777
1778 return {};
1779}
1780//-----------------------------------------------------------------------------
1781
1782void CodeGenerator::InsertTemplateParameters(const TemplateParameterList& list,

Callers 2

InsertTemplateArgMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected