Implementing the spaceship operator for optional

  • optional<T> compares to optional<U>, where valid (6 functions).
  • optional<T> compares to U, where valid (12 functions). I’m skeptical of this particular use-case, but this post is all about implementing the spec.
  • optional<T> compares to nullopt_t (12 functions). This case is trivial to implement, since several of the operations are simply constants (e.g. operator>=(optional<T>, nullopt_t) is true). But, that’s still 12 trivial-to-implement functions.
The comparison categories for the spaceship operator

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

0% Fee withdrawals of RUB with Advcash!

Facebook Solutions Engineering: 5 Year Retrospective

Data Management in Automation Testing

Important CSS Properties Part Three

Faveo Integration with Facebook Messenger[WEBINAR]

Starting of my python journey .

An honest review of Insomnia Designer and Insomnia Core

The LEGO bricks of digitization  are waiting for you

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Barry Revzin

Barry Revzin

More from Medium

cpm-rs, a rust crate for Critical Path Method

Load Testing Cute Server With 1M WebSocket Connections

Save Display Configuration after reboot

104. Maximum Depth of Binary Tree