Coder Social home page Coder Social logo

Comments (3)

jzmaddock avatar jzmaddock commented on July 18, 2024

I'm having a hard time thinking of a use case for that - can you elaborate some more?

from type_traits.

jzmaddock avatar jzmaddock commented on July 18, 2024

Closing as extra information not supplied.

from type_traits.

lpranam avatar lpranam commented on July 18, 2024

I'm having a hard time thinking of a use case for that - can you elaborate some more?

@jzmaddock this is a useful utility and I have used it in my GSoC project (boost.astronomy) too. A simplified example is as follows:

Taking the standard example of shapes to demonstrate the inheritance but this time also providing g units with the measurements using boost.units and boost.geometry.

template <typename CoordinateSystem, typename CoordinateType>
struct base{};

template<
    typename CoordinateType,
    typename XQuantity,
    typename YQuantity,
    typename ZQuantity
>
struct cartesian: base<bg::cs::cartesian, CoordinateType>{};

template<
    typename CoordinateType,
    typename LatQuantity,
    typename LonQuantity,
    typename DistQuantity
>
struct spherical: base<bg::cs::spherical<radian>, CoordinateType>{};

template <typename Coordinate_1, typename Coordinate_2>
Coordinate_1 sum(Coordinate_1 coordinate1, Coordinate_2 coordinate2)
{
    static_assert(is_base_template_of<base, Coordinate_1>::value, "Not a valid argument!");
    static_assert(is_base_template_of<base, Coordinate_2>::value, "Not a valid argument!");
    //code
}

Here such utility comes handy because I don't care what type of units are used because they will be converted internally.

More example can be found in coordinate module of boost.astronomy.

If this seems nice then I can also send PR for the same.

from type_traits.

Related Issues (20)

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.