boost optional

This is a discussion on boost optional within the C++ Programming forums, part of the General Programming Boards category; Suppose I have: Code: boost::optional<someobject&> test = get_someobject(); if (test) { someobject &ref = *test; } How can I assign ...

  1. #1
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630

    boost optional

    Suppose I have:

    Code:
    boost::optional<someobject&>  test = get_someobject();
    
    if (test) {
       someobject &ref = *test;
    }
    How can I assign reference (ref) to someobject object?

    Thanks for help

    Regards

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    Through value access:

    inline T& get (optional<T&> &) ;
    inline T const& get (optional<T&> const& ) ;

    If if remember correctly
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Boost Auto-Linking
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 12-30-2007, 05:11 AM
  2. Replies: 2
    Last Post: 12-12-2007, 05:45 AM
  3. Boost and Size
    By CrazyNorman in forum C++ Programming
    Replies: 3
    Last Post: 07-13-2007, 12:07 PM
  4. building boost iostreams
    By l2u in forum C++ Programming
    Replies: 3
    Last Post: 04-14-2007, 02:29 PM
  5. Integrating Boost with STLPort
    By Mario F. in forum Tech Board
    Replies: 1
    Last Post: 11-11-2006, 05:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21