Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
cast.h File Reference

Hand-rolled LLVM-style RTTI system for class hierarchies where dynamic_cast isn't fast enough. More...

Go to the source code of this file.

Functions

template<typename T , typename S >
bool is (S const *s)
 Equivalent to the boolean value of dynamic_cast<T const*>(...).
 
template<typename T , typename S >
auto cast_unsafe (S *s)
 Equivalent to static_cast<T [const]*>(...) where the const is deduced.
 
template<typename T , typename S >
auto cast_unsafe (S const *s)
 
template<typename T , typename S >
auto cast (S *s)
 Equivalent to dynamic_cast<T [const]*>(...) where the const is deduced.
 

Variables

template<typename T >
constexpr int first_tag = std::enable_if<!sizeof(T), void>::value
 
template<typename T >
constexpr int last_tag = std::enable_if<!sizeof(T), void>::value
 
template<typename T >
constexpr int tag_of = first_tag<std::remove_cv_t<std::remove_reference_t<T>>>
 Convenience function to retrieve the tag (class id) of a given type.
 

Detailed Description

Hand-rolled LLVM-style RTTI system for class hierarchies where dynamic_cast isn't fast enough.

Definition in file cast.h.

Function Documentation

◆ cast()

template<typename T , typename S >
auto cast ( S *  s)

Equivalent to dynamic_cast<T [const]*>(...) where the const is deduced.

If the supplied pointer is null, the result is null.

To help catch redundant casts, casts that are known at compile time currently generate a compile error. Please feel free to remove these static_asserts if they become unhelpful.

Definition at line 76 of file cast.h.

◆ cast_unsafe() [1/2]

template<typename T , typename S >
auto cast_unsafe ( S *  s)

Equivalent to static_cast<T [const]*>(...) where the const is deduced.

Definition at line 56 of file cast.h.

◆ cast_unsafe() [2/2]

template<typename T , typename S >
auto cast_unsafe ( S const *  s)

Definition at line 62 of file cast.h.

◆ is()

template<typename T , typename S >
bool is ( S const *  s)

Equivalent to the boolean value of dynamic_cast<T const*>(...).

If the supplied pointer is null, the check fails.

To help catch redundant checks, checks that are known at compile time currently generate a compile error. Please feel free to remove these static_asserts if they become unhelpful.

Definition at line 37 of file cast.h.

Referenced by Geom::PlanarGraph< EdgeLabel >::_reglueTangentFan(), GlyphNames::contains(), Inkscape::UI::Dialog::SvgFontsDialog::glyph_advance_edit(), vpsc::RectangleIntersections::nearest(), and SPMeshNodeArray::write().

Variable Documentation

◆ first_tag

template<typename T >
constexpr int first_tag = std::enable_if<!sizeof(T), void>::value
inlineconstexpr

Definition at line 20 of file cast.h.

◆ last_tag

template<typename T >
constexpr int last_tag = std::enable_if<!sizeof(T), void>::value
inlineconstexpr

Definition at line 21 of file cast.h.

◆ tag_of

template<typename T >
constexpr int tag_of = first_tag<std::remove_cv_t<std::remove_reference_t<T>>>
inlineconstexpr

Convenience function to retrieve the tag (class id) of a given type.

Definition at line 26 of file cast.h.

Referenced by Inkscape::DrawingItem::tag(), SPObject::tag(), Inkscape::DrawingGroup::tag(), Inkscape::DrawingImage::tag(), Inkscape::DrawingPattern::tag(), Inkscape::DrawingShape::tag(), Inkscape::DrawingGlyphs::tag(), Inkscape::DrawingText::tag(), LivePathEffectObject::tag(), Box3DSide::tag(), SPBox3D::tag(), Inkscape::ColorProfile::tag(), SPFeBlend::tag(), SPFeColorMatrix::tag(), SPFeFuncNode::tag(), SPFeComponentTransfer::tag(), SPFeComposite::tag(), SPFeConvolveMatrix::tag(), SPFeDiffuseLighting::tag(), SPFeDisplacementMap::tag(), SPFeDistantLight::tag(), SPFeFlood::tag(), SPGaussianBlur::tag(), SPFeImage::tag(), SPFeMerge::tag(), SPFeMergeNode::tag(), SPFeMorphology::tag(), SPFeOffset::tag(), SPFePointLight::tag(), SPFilterPrimitive::tag(), SPFeSpecularLighting::tag(), SPFeSpotLight::tag(), SPFeTile::tag(), SPFeTurbulence::tag(), Persp3D::tag(), SPAnchor::tag(), SPClipPath::tag(), SPDefs::tag(), SPDesc::tag(), SPGenericEllipse::tag(), SPFilter::tag(), SPFlowdiv::tag(), SPFlowtspan::tag(), SPFlowpara::tag(), SPFlowline::tag(), SPFlowregionbreak::tag(), SPFlowregion::tag(), SPFlowregionExclude::tag(), SPFlowtext::tag(), SPFontFace::tag(), SPFont::tag(), SPGlyphKerning::tag(), SPHkern::tag(), SPVkern::tag(), SPGlyph::tag(), SPGradient::tag(), SPGrid::tag(), SPGuide::tag(), SPHatchPath::tag(), SPHatch::tag(), SPImage::tag(), SPGroup::tag(), SPItem::tag(), SPLine::tag(), SPLinearGradient::tag(), SPLPEItem::tag(), SPMarker::tag(), SPMask::tag(), SPMeshGradient::tag(), SPMeshpatch::tag(), SPMeshrow::tag(), SPMetadata::tag(), SPMissingGlyph::tag(), SPNamedView::tag(), SPObjectGroup::tag(), SPOffset::tag(), SPPage::tag(), SPPaintServer::tag(), SPPath::tag(), SPPattern::tag(), SPPolygon::tag(), SPPolyLine::tag(), SPRadialGradient::tag(), SPRect::tag(), SPRoot::tag(), SPScript::tag(), SPShape::tag(), SPSolidColor::tag(), SPSpiral::tag(), SPStar::tag(), SPStop::tag(), SPString::tag(), SPStyleElem::tag(), SPSwitch::tag(), SPSymbol::tag(), SPTagUse::tag(), SPTag::tag(), SPText::tag(), SPTextPath::tag(), SPTitle::tag(), SPTRef::tag(), SPTSpan::tag(), and SPUse::tag().