Coder Social home page Coder Social logo

fastcast's Introduction

FASTCAST
--------

The goal of fastcast is to provide a fast alternative to dynamic_cast.
Each class in the hierarchy has an integer identifier. This identifier is built to make instanceof operation very fast.

Usage :
-----

Fastcast is easy to use:
i) include fastcast.hxx
ii) the root class (say A) must inherit from fastcast::fcast<A, uint64_t> (or an other integer type)
iii) each class in the hierarchy having children must typedef a fcast_hierarchy:

// typedef for the root class
typedef fastcast::hierarchy<fastcast::root, fastcast::children<B, C>> fcast_hierarchy;

// typedef for a class other than root
// The first template parameter gives the parent
// and the second define the children
typedef fastcast::hierarchy<A, fastcast::children<D>> fcast_hierarchy;

// here there is no child
typedef fastcast::hierarchy<D> fcast_hierarchy;

iv) Each ctor must set the identifier for the class:
struct B : public A
{
    typedef fastcast::hierarchy<A, fastcast::children<D>> fcast_hierarchy;

    B() { fastcast::fcast<A, uint32_t>::set_id<B>(); }
};

v) the file test.cpp could be compiled in using:

clang++ -std=c++11 -oout test/test.cpp -I. && ./out

or

g++ -std=c++11 -oout test/test.cpp -I. && ./out

fastcast's People

Contributors

calixteman avatar

Watchers

David Godfrey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.