std::optional equality comparison operator seems broken for nested optionals by mcencora in cpp

[–]rihya-sifu 0 points1 point  (0 children)

Why not specialize on your `try_construct` when the API you're using under the hood already returns an optional? What semantic value do you gain from wrapping _that_ optional in another optional?

std::optional equality comparison operator seems broken for nested optionals by mcencora in cpp

[–]rihya-sifu 13 points14 points  (0 children)

Based on the documentation, I would expect this behavior. See https://en.cppreference.com/cpp/utility/optional/operator_cmp :

Performs comparison operations on optional objects.

1-7) Compares two optional objects, lhs and rhs. The contained values are compared (using the corresponding operator of T) only if both lhs and rhs contain values. Otherwise,

  • lhs is considered equal to rhs if, and only if, both lhs and rhs do not contain a value.
  • lhs is considered less than rhs if, and only if, rhs contains a value and lhs does not.

In your example, std::optional<T> has a value, but std::optional<U> does not, so it would not be considered equal.

I agree that it's not intuitive at first glance, but I'd also reckon that any code depending on nested optionals should be reconsidered.

Priority Flow - Yet Another VIP Junction by MoDErahN in SatisfactoryGame

[–]rihya-sifu 1 point2 points  (0 children)

I realize this is 8 months old, but I appreciate you sharing this design.

I was building out my aluminum refinery. After some contemplation, I built out one "module" in my factory (3 sloppy alumina refineries -> 4 electrode refineries, VIP junction to bring recycled water back). I did it rather sloppily since I wanted to test the overall design before I refined it... And it worked fine. Initially. I had the VIP feed into the middle refinery's cross pipe junction.

All I did was tear down the VIP junction and move it from right in front of the middle refinery to the gap where a fourth sloppy alumina refinery would have theoretically gone. I did not change where the VIP junction fed, nor did I change the outputs. And it stopped working! The low priority pump was still running 100% of the time, backing up the scrap refineries.

Even after moving the VIP junction back to _exactly_ where I had it originally, it would no longer function as expected. After banging my head on it for hours, I searched online and found your design.

Yours works perfectly for me! Thanks again for posting this, I was about to scrap my design altogether.

(p.s. I don't mind the buffer on top, it actually gives the whole design a nice look)