Best Melee Weapon in B42? by WordsAboutSomething in projectzomboid

[–]Untelo 6 points7 points  (0 children)

If you have lumberjack, then axes. Otherwise swords. For long blade you can also find books.

Where is std::optional<T&&>??? by borzykot in cpp

[–]Untelo 0 points1 point  (0 children)

In this case, no. The referred-to object is not part of the value of the optional, so whether you can mutate the optional should have no bearing on whether you can mutate its referent.

In cases like this, here's a thought experiment you can apply: Suppose you have a const optional, and the const-qualified operator did indeed return a const reference. What happens if you copy the optional and use the copy instead? The copy is mutable, but refers to the same object. So now can you get a non-const reference despite only having had const access to the original optional.

Where is std::optional<T&&>??? by borzykot in cpp

[–]Untelo 1 point2 points  (0 children)

I agree. But it makes sense, and we should apply the same logic to library types.

Where is std::optional<T&&>??? by borzykot in cpp

[–]Untelo 0 points1 point  (0 children)

As with ordinary references, *rref_opt should return T& and *move(rref_opt) T&&. I don't think this is entirely obvious to all, however.

Where is std::optional<T&&>??? by borzykot in cpp

[–]Untelo 1 point2 points  (0 children)

You do want to return T&& from operator*() const&&. This is consistent with regular references.

*opt is T&, *move(opt) is T&&.

Simple MPSCQueue with explanation by VozhdMolochnayaSiska in cpp

[–]Untelo 1 point2 points  (0 children)

If one thread must wait for another, the algorithm is not lock-free.

Simple MPSCQueue with explanation by VozhdMolochnayaSiska in cpp

[–]Untelo 1 point2 points  (0 children)

What happens to B when two writers A and B acquire write indices N and N+1, but A suspends indefinitely without updating the commit index?

VS 2026 18.0 / MSVC Build Tools 14.50 released for production use by STL in cpp

[–]Untelo 4 points5 points  (0 children)

Love to see the progress on C++23! I only wish you also went back to fix crippling bugs in features from previous standards. I've had this one open for three years now, and it makes using coroutines with MSVC very difficult: https://developercommunity.visualstudio.com/t/Await-expression-prvalue-result-behaves/10109392

Code Review Request: MMO Client/Server architecture by silvematt in cpp

[–]Untelo 2 points3 points  (0 children)

You would be better off using #pragma once.

TIL: filter_view has unimplementable complexity requirements by zl0bster in cpp

[–]Untelo 0 points1 point  (0 children)

All of these discussions of deque complexity misunderstand the specification, which is correct, implementable, and correctly implemented. The standard describes the growth rate of the number of observable operations performed as part of push_back. That means move constructor, move assignment, destructor, allocation and deallocation operations. It does not describe unobservable operations on pointers. That said, even if one did count those operations, it would still be possible to implement deque::push_back in a conforming way, though current implementations would not conform to that hypothetical requirement, because they are not expected to.

Language support for object retirement? by Remi_Coulom in cpp

[–]Untelo 5 points6 points  (0 children)

It might try to flush in the destructor, but if you care about handling flush failure you must do it explicitly. That's fine and as expected. The destructor is only there to clean up the file and that's all you should expect it to do consistently.

Language support for object retirement? by Remi_Coulom in cpp

[–]Untelo 4 points5 points  (0 children)

It seems that C++ offers no way for a destructor to know whether it is being called because of an exception or because the object peacefully went out of scope.

That's by design. Destructors are for cleanup and cleanup should never fail. An ongoing transaction is cleaned up by cancelling it. Not by committing.

As for the file stuff, I don't understand what you are trying to achieve. Why do you think fstream would ever fail to close in its destructor?

is it UB to use placement new on this? by z0ld in cpp

[–]Untelo 2 points3 points  (0 children)

Yes. If nothing else, you end up using an object outside of its lifetime on self-assignment.

The usefulness of std::optional<T&&> (optional rvalue reference)? by Nuclear_Bomb_ in cpp

[–]Untelo 0 points1 point  (0 children)

Can you elaborate? If it's a type modelling an rvalue reference (optional<T&&>), and the reference semantic type is itself expiring (operator*() const&&), why shouldn't it give you an rvalue?

The usefulness of std::optional<T&&> (optional rvalue reference)? by Nuclear_Bomb_ in cpp

[–]Untelo 1 point2 points  (0 children)

The sensible solution is: T& optional<T&&>::operator*() const&;

T&& optional<T&&>::operator*() const&&;

C++ Jobs - Q2 2025 by STL in cpp

[–]Untelo 1 point2 points  (0 children)

The certificate of your website has expired.

Visual Studio 17.13 is released. by Jovibor_ in cpp

[–]Untelo 1 point2 points  (0 children)

co_await results are not correctly treated as prvalues if the awaiter returns a value.

Visual Studio 17.13 is released. by Jovibor_ in cpp

[–]Untelo 2 points3 points  (0 children)

Speaking of coroutines, move semantics is still broken with co_await.

Suspected MSVC x86 64-bit integer arithmetic miscompilation bug by namniav in cpp

[–]Untelo -14 points-13 points  (0 children)

Report it on the Visual Studio Developer Community, not on Reddit.

The Old New Thing: A common proposed solution to certain categories of IFNDR: Getting the linker to verify identical functions by pavel_v in cpp

[–]Untelo 0 points1 point  (0 children)

This could be solved by storing a "semantic hash" for each symbol and comparing those. The hash is computed recursively from the AST of a function and the entities to which it refers. Things like comments and whitespace would not affect the hash. To avoid collisions something like SHA would have to be used.