Giter Site home page Giter Site logo

Comments (2)

robUx4 avatar robUx4 commented on August 11, 2024

It works if we store the EbmlDocVersion as a pointer and have an actual instance of the version kept in memory. Maybe we can store it as a reference but we can't initialize it the ways we do not. Or maybe it needs a copy constructor in EbmlDocVersion and MatroskaProfile ?

from libmatroska.

robUx4 avatar robUx4 commented on August 11, 2024

The code above doesn't work because the MatroskaProfile passed to the constructor is a temporary value. The object is destroyed after the initialization (in the static + global variables). The references point to a dead/reused memory location.

Example with this:

class A {
public:
    constexpr A(bool i) : toto(i?1:0) {}
    const int toto;
};

class B : public A {
public:
    constexpr B(bool o, bool i) : A(o), titi(i) {}
    const bool titi;
};

class holder {
public:
    constexpr holder(const A & ref)
    :myref(ref)
    {}

    const A & myref;
};

const holder holder_local(B(true, false));
constexpr const holder holder_local_expr(B{true, false});

The second constructor fails to compile because the constructor is a temporary value.

So we need to make the MatroskaProfile passed to the EbmlCallbacks constructor actual object instances kept in memory. If we can manage to turn the global EbmlCallbacks instances constexpr, it should generate build failure when not used properly, as in the example above.

from libmatroska.

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.