当前位置: 首页>>代码示例>>C++>>正文


C++ TemplateArgument::pack_elements方法代码示例

本文整理汇总了C++中TemplateArgument::pack_elements方法的典型用法代码示例。如果您正苦于以下问题:C++ TemplateArgument::pack_elements方法的具体用法?C++ TemplateArgument::pack_elements怎么用?C++ TemplateArgument::pack_elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TemplateArgument的用法示例。


在下文中一共展示了TemplateArgument::pack_elements方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddTemplateArgument

void ODRHash::AddTemplateArgument(TemplateArgument TA) {
  const auto Kind = TA.getKind();
  ID.AddInteger(Kind);

  switch (Kind) {
    case TemplateArgument::Null:
      llvm_unreachable("Expected valid TemplateArgument");
    case TemplateArgument::Type:
      AddQualType(TA.getAsType());
      break;
    case TemplateArgument::Declaration:
      AddDecl(TA.getAsDecl());
      break;
    case TemplateArgument::NullPtr:
    case TemplateArgument::Integral:
      break;
    case TemplateArgument::Template:
    case TemplateArgument::TemplateExpansion:
      AddTemplateName(TA.getAsTemplateOrTemplatePattern());
      break;
    case TemplateArgument::Expression:
      AddStmt(TA.getAsExpr());
      break;
    case TemplateArgument::Pack:
      ID.AddInteger(TA.pack_size());
      for (auto SubTA : TA.pack_elements()) {
        AddTemplateArgument(SubTA);
      }
      break;
  }
}
开发者ID:Teemperor,项目名称:clang,代码行数:31,代码来源:ODRHash.cpp

示例2: if

Optional<unsigned> Sema::getFullyPackExpandedSize(TemplateArgument Arg) {
  assert(Arg.containsUnexpandedParameterPack());

  // If this is a substituted pack, grab that pack. If not, we don't know
  // the size yet.
  // FIXME: We could find a size in more cases by looking for a substituted
  // pack anywhere within this argument, but that's not necessary in the common
  // case for 'sizeof...(A)' handling.
  TemplateArgument Pack;
  switch (Arg.getKind()) {
  case TemplateArgument::Type:
    if (auto *Subst = Arg.getAsType()->getAs<SubstTemplateTypeParmPackType>())
      Pack = Subst->getArgumentPack();
    else
      return None;
    break;

  case TemplateArgument::Expression:
    if (auto *Subst =
            dyn_cast<SubstNonTypeTemplateParmPackExpr>(Arg.getAsExpr()))
      Pack = Subst->getArgumentPack();
    else if (auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.getAsExpr()))  {
      for (ParmVarDecl *PD : *Subst)
        if (PD->isParameterPack())
          return None;
      return Subst->getNumExpansions();
    } else
      return None;
    break;

  case TemplateArgument::Template:
    if (SubstTemplateTemplateParmPackStorage *Subst =
            Arg.getAsTemplate().getAsSubstTemplateTemplateParmPack())
      Pack = Subst->getArgumentPack();
    else
      return None;
    break;

  case TemplateArgument::Declaration:
  case TemplateArgument::NullPtr:
  case TemplateArgument::TemplateExpansion:
  case TemplateArgument::Integral:
  case TemplateArgument::Pack:
  case TemplateArgument::Null:
    return None;
  }

  // Check that no argument in the pack is itself a pack expansion.
  for (TemplateArgument Elem : Pack.pack_elements()) {
    // There's no point recursing in this case; we would have already
    // expanded this pack expansion into the enclosing pack if we could.
    if (Elem.isPackExpansion())
      return None;
  }
  return Pack.pack_size();
}
开发者ID:PolyJIT,项目名称:clang,代码行数:56,代码来源:SemaTemplateVariadic.cpp

示例3: VisitTemplateArgument

void USRGenerator::VisitTemplateArgument(const TemplateArgument &Arg) {
  switch (Arg.getKind()) {
  case TemplateArgument::Null:
    break;

  case TemplateArgument::Declaration:
    Visit(Arg.getAsDecl());
    break;

  case TemplateArgument::NullPtr:
    break;

  case TemplateArgument::TemplateExpansion:
    Out << 'P'; // pack expansion of...
    // Fall through
  case TemplateArgument::Template:
    VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
    break;

  case TemplateArgument::Expression:
    // FIXME: Visit expressions.
    break;

  case TemplateArgument::Pack:
    Out << 'p' << Arg.pack_size();
    for (const auto &P : Arg.pack_elements())
      VisitTemplateArgument(P);
    break;

  case TemplateArgument::Type:
    VisitType(Arg.getAsType());
    break;

  case TemplateArgument::Integral:
    Out << 'V';
    VisitType(Arg.getIntegralType());
    Out << Arg.getAsIntegral();
    break;
  }
}
开发者ID:hsorby,项目名称:opencor,代码行数:40,代码来源:USRGeneration.cpp

示例4: VisitTemplateArgument

void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
  // Mostly repetitive with TemplateArgument::Profile!
  ID.AddInteger(Arg.getKind());
  switch (Arg.getKind()) {
  case TemplateArgument::Null:
    break;

  case TemplateArgument::Type:
    VisitType(Arg.getAsType());
    break;

  case TemplateArgument::Template:
  case TemplateArgument::TemplateExpansion:
    VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
    break;
      
  case TemplateArgument::Declaration:
    VisitDecl(Arg.getAsDecl());
    break;

  case TemplateArgument::NullPtr:
    VisitType(Arg.getNullPtrType());
    break;

  case TemplateArgument::Integral:
    Arg.getAsIntegral().Profile(ID);
    VisitType(Arg.getIntegralType());
    break;

  case TemplateArgument::Expression:
    Visit(Arg.getAsExpr());
    break;

  case TemplateArgument::Pack:
    for (const auto &P : Arg.pack_elements())
      VisitTemplateArgument(P);
    break;
  }
}
开发者ID:danteinforno,项目名称:clang,代码行数:39,代码来源:StmtProfile.cpp

示例5: printTemplateArgument

// Adapted from tools\clang\lib\AST\TemplateBase.cpp TemplateArgument::print
void printTemplateArgument(raw_ostream &out, const PrintingPolicy &policy, TemplateArgument const &arg, bool qualifyNames)
{
    switch (arg.getKind()) {
    case TemplateArgument::Null:
        out << "(no value)";
        break;

    case TemplateArgument::Type: {
        PrintingPolicy SubPolicy(policy);
        SubPolicy.SuppressStrongLifetime = true;
        arg.getAsType().print(out, SubPolicy);
        break;
    }

    case TemplateArgument::Declaration: {
        NamedDecl *ND = cast<NamedDecl>(arg.getAsDecl());
        out << '&';
        if (ND->getDeclName()) {
            // FIXME: distinguish between pointer and reference args?
            ND->printQualifiedName(out);
        }
        else {
            out << "(anonymous)";
        }
        break;
    }

    case TemplateArgument::NullPtr:
        out << "nullptr";
        break;

    case TemplateArgument::Template:
        // Orig: arg.getAsTemplate().print(out, policy);
    {
        auto templateName = arg.getAsTemplate();
        printTemplateName(out, policy, templateName, qualifyNames);
        break;
    }

    case TemplateArgument::TemplateExpansion:
        arg.getAsTemplateOrTemplatePattern().print(out, policy);
        out << "...";
        break;

    case TemplateArgument::Integral: {
        printIntegral(arg, out, policy);
        break;
    }

    case TemplateArgument::Expression:
        arg.getAsExpr()->printPretty(out, nullptr, policy);
        break;

    case TemplateArgument::Pack:
        out << "<";
        bool First = true;
        for (const auto &P : arg.pack_elements()) {
            if (First)
                First = false;
            else
                out << ", ";

            P.print(policy, out);
        }
        out << ">";
        break;
    }
}
开发者ID:CAST-projects,项目名称:Clang-ast-viewer,代码行数:69,代码来源:TemplateUtilities.cpp


注:本文中的TemplateArgument::pack_elements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。