The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

265818 (18) [Avatar] Offline
#1
I do no understand the return type of this function in Listing 6.10:

     bool try_pop(T& value)
    {
        std::unique_ptr<node> const old_head=try_pop_head(value);
        return old_head;
    }


I was thinking it might be correct as:

   bool try_pop(T& value) {
    std::unique_ptr<node> const old_head=try_pop_head(value);
    return old_head?true:false;
  }


Would you please give me an explanation? Thank you very much.
Marco
georger.araujo (6) [Avatar] Offline
#2
I suppose that is std::unique_ptr::operator bool in action? If that's the case, the ternary operator is unnecessary.