LLVM  6.0.0svn
Public Member Functions | Public Attributes | List of all members
llvm::Printable Class Reference

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

#include "llvm/Support/Printable.h"

Collaboration diagram for llvm::Printable:
Collaboration graph

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)

Definition at line 41 of file Printable.h.

Member Data Documentation

◆ Print

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

Definition at line 40 of file Printable.h.

Referenced by llvm::operator<<().

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