Login
You're viewing the techdon.dev public feed.
  • Nov 11, 2026, 10:01 PM

    Fucked C++ question:

    I have a struct B, defined by me. I had the code

    auto &b = bees.emplace_back(); //vector
    b.value = 3;

    A change *ELSEWHERE IN THE CODE* caused this to suddenly start failing with

    "auto cannot be inferred"
    changed the line to
    B &b = bees.emplace_back();
    The error became ("bees" underlined):
    "initial value of reference to non-const must be an lvalue" (??)

    Replaced the whole thing with
    B b;
    b.value = e;
    bees.push_back(b);

    The compiler allows this.

    C++17.

    wha ??? ?? ?????

    💬 0🔄 2⭐ 5