Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

While implementing and using my interval map my interval map I needed to return an optional reference in one of its accessor methods, namely operator[](Key). The idea is to get a reference to a stored value or nothing. Thus I did it there with an std::optional<std::reference_wrapper<const T>>. Following this pattern of optional refs led to complications when I tried accessing an std::optional<std::reference_wrapper<T>> at some other point of time. I couldn't write something like this

While implementing and using my interval map I needed to return an optional reference in one of its accessor methods, namely operator[](Key). The idea is to get a reference to a stored value or nothing. Thus I did it there with an std::optional<std::reference_wrapper<const T>>. Following this pattern of optional refs led to complications when I tried accessing an std::optional<std::reference_wrapper<T>> at some other point of time. I couldn't write something like this

While implementing and using my interval map I needed to return an optional reference in one of its accessor methods, namely operator[](Key). The idea is to get a reference to a stored value or nothing. Thus I did it there with an std::optional<std::reference_wrapper<const T>>. Following this pattern of optional refs led to complications when I tried accessing an std::optional<std::reference_wrapper<T>> at some other point of time. I couldn't write something like this

Tweeted twitter.com/StackCodeReview/status/849383790275436545
edited tags
Link
200_success
  • 145.6k
  • 22
  • 190
  • 479
edited body
Source Link
Maikel
  • 750
  • 1
  • 5
  • 15
Loading
Source Link
Maikel
  • 750
  • 1
  • 5
  • 15
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /