Giter VIP home page Giter VIP logo

Comments (9)

antisvin avatar antisvin commented on May 30, 2024 1

I would be fine using either version, but C++11 is used by existing build system. So I'm not really making a choice in this case.

I've opened this issue because recent commit broke compatibility due to including code that is not even used by library itself. This looks like an unintended regression. So this can be either fixed in library or just by using custom dsp.h implementation that doesn't include those unused functions.

from daisysp.

antisvin avatar antisvin commented on May 30, 2024 1

I don't see any problems with this approach, this difference in behavior won't matter since the functions are not used by library. Maybe add a short comment explaining why it's done like that.

As a solution to more general problem of supporting multiple C++ versions, maybe CI could be configured to make several runs targeting each C++ standard version that would be considered supported? Such list of supported versions doesn't even seem to be even documented/stated anywhere.

from daisysp.

TheSlowGrowth avatar TheSlowGrowth commented on May 30, 2024

Do you actually need C++11? It's pretty ancient... Sure. Things can be refactored, but why?

from daisysp.

stephenhensley avatar stephenhensley commented on May 30, 2024

While not currently used, I do see the value of a helper function like this.

I'm in favor of either guarding it by a check for the c++ version, or making it a standard function instead of constexpr on versions less than c++14. Something like:

#if __cplusplus <= 201103L
uint32_t get_next_power2(uint32_t x)
#else
constexpr uint32_t get_next_power2(uint32_t x)
#endif
{
    // function body
    return x;
}

It is a bit messy looking, and leads to different behavior on different c++ versions, but it might be a good solution. If we start doing this more than just here, we should probably make a specific macro for that check.

I can make a PR if everyone likes this idea. I'm also open to other ideas.

from daisysp.

polyclash avatar polyclash commented on May 30, 2024

constexpr have copile time optimization benefits if its input isn't const?

from daisysp.

TheSlowGrowth avatar TheSlowGrowth commented on May 30, 2024

No, but constexpr adds the ability to be evaluated at compile time which can (if used accordingly) have a big impact on the performance. Honestly, I don't understand why constexpr isn't the default.

from daisysp.

TheSlowGrowth avatar TheSlowGrowth commented on May 30, 2024

@stephenhensley The code could be much tidier like this:

// somewhere in platform.h
#if __cplusplus <= 201103L
#   define D_CONSTEXPR constexpr
#else
#   define D_CONSTEXPR
#endif

// elswhere in daisySP
#include "platform.h"
D_CONSTEXPR uint32_t get_next_power2(uint32_t x)
{
    // function body
    return x;
}

from daisysp.

antisvin avatar antisvin commented on May 30, 2024

Introducing a separate preprocessor variable for the sake of this looks a bit excessive to me. Especially coming from someone who advocates abandoning ancient C++ versions ;-)

from daisysp.

stephenhensley avatar stephenhensley commented on May 30, 2024

Yeah, I think if this is an exception, and not a general rule we can leave it semi-ugly to make it a point that it's not idiomatic with the rest of the library. However, if this becomes a trend with other helpers we can add any necessary preprocessors.

I just opened a PR for this #159 -- I'll give it a quick compile/test on multiple on c++11 in the morning. So feel free to weigh in if anyone thinks anything should change.

from daisysp.

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.