Opened 16 years ago

Closed 12 years ago

#816 closed Support Requests (fixed)

duplicat initial members -> erase_key postcond. fail

Reported by: cppljevans Owned by: Aleksey Gurtovoy
Milestone: Boost 1.46.0 Component: mpl
Version: None Severity: Problem
Keywords: Cc: agurtovoy@…

Description (last modified by Marshall Clow)

has_key<erase_key<set<T,T>,T>::type>type::value==true
in violation of Postcondition on
http://www.boost.org/libs/mpl/doc/refmanual/erase-key.html .

Attachments (2)

assoc_by_insert.cpp (3.7 KB ) - added by cppljevans@… 13 years ago.
solution using superclass which is fold over insert op
set.rst (8.7 KB ) - added by cppljevans@… 13 years ago.
Solution which just adds warning in docs

Download all attachments as: .zip

Change History (7)

comment:1 by cppljevans, 16 years ago

Logged In: YES 
user_id=24558
Originator: YES

The attached file has assoc_item template showing how to check for duplicates
using a boost concept template.  Although it can only be compiled with
Doug's variadic template compiler, the method used to check for duplicates
can, AFAICT, be used with the current m_item and s_item templates in
the current mpl library.  This is because the method used just
uses a slight variation of the static value_by_key which the
current mpl assoc containers already use. 
File Added: cons_inherit_check_test.cpp

comment:2 by Marshall Clow, 15 years ago

Component: Nonempl
Description: modified (diff)
Severity: Problem

by cppljevans@…, 13 years ago

Attachment: assoc_by_insert.cpp added

solution using superclass which is fold over insert op

comment:3 by anonymous, 13 years ago

The previous comment referring to assoc_item was from:

https://sourceforge.net/tracker/?func=detail&atid=207586&aid=1642614&group_id=7586

The recent assoc_by_insert.cpp attachment shows simpler solution which folds over the set insert operation instead of the set s_item operation in the superclass of set<T1,T2,...,Tn> The reason it works is because the fold starts from the empty set, which has no duplicates, and the insert operation preserves the no duplicate invariant.

by cppljevans@…, 13 years ago

Attachment: set.rst added

Solution which just adds warning in docs

comment:4 by cppljevans@…, 13 years ago

The just attached set.rst is another solution which just adds a warning to the docs.

This set.rst is a replacement for that in libs/mpl/doc/src/refmanual/set.rst.

comment:5 by Aleksey Gurtovoy, 12 years ago

Cc: agurtovoy@… added
Milestone: Boost 1.46.0
Resolution: Nonefixed
Status: assignedclosed

Added a corresponding note and example to the docs.

Note: See TracTickets for help on using tickets.