LLVM 22.0.0git
llvm::Printable Class Reference

Simple wrapper around std::function<void(raw_ostream&)>. More...

#include "llvm/Support/Printable.h"

Public Member Functions

 Printable (std::function< void(raw_ostream &OS)> Print)

Public Attributes

std::function< void(raw_ostream &OS)> Print

Detailed Description

Simple wrapper around std::function<void(raw_ostream&)>.

This class is useful to construct print helpers for raw_ostream.

Example: Printable printRegister(unsigned Register) { return Printable([Register](raw_ostream &OS) { OS << getRegisterName(Register); }); } ... OS << printRegister(Register); ...

Implementation note: Ideally this would just be a typedef, but doing so leads to operator << being ambiguous as function has matching constructors in some STL versions. I have seen the problem on gcc 4.6 libstdc++ and microsoft STL.

Definition at line 38 of file Printable.h.

Constructor & Destructor Documentation

◆ Printable()

llvm::Printable::Printable ( std::function< void(raw_ostream &OS)> Print)
inline

Definition at line 41 of file Printable.h.

References llvm::move(), and Print.

Member Data Documentation

◆ Print

std::function<void(raw_ostream &OS)> llvm::Printable::Print

Definition at line 40 of file Printable.h.

Referenced by Printable().


The documentation for this class was generated from the following file: