[Boost-bugs] [Boost C++ Libraries] #3326: struct tagging in constructor stops conditional construction without .swap call

Subject: [Boost-bugs] [Boost C++ Libraries] #3326: struct tagging in constructor stops conditional construction without .swap call
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-08-07 16:57:41


#3326: struct tagging in constructor stops conditional construction without .swap
call
-----------------------------------------------------------+----------------
 Reporter: Andy Schneider <andrew.schneider@…> | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: interprocess
  Version: Boost 1.39.0 | Severity: Cosmetic
 Keywords: |
-----------------------------------------------------------+----------------
 I'd like to do this:

    shared_memory_object shm_obj
       (isOwner ? create_only : open_only
       ,"shared_memory" //name
       ,read_write //read-write mode
       );

 but I don't seem to be able to because create_only and open_only are tag
 structs.

 Instead I end up with something like this:

 shared_memory_object shm;

 if (isOwner)
 {
     shared_memory_object shm_obj (...)
     shm_obj.swap (shm);
 }
 else
 {
     shared_memory_object shm_obj (...)
     shm_obj.swap (shm);
 }

 which isn't as clean imho. What's the rational for a tag struct rather
 than enum?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3326>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC