Boost logo

Boost :

Subject: [boost] fusion concepts
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-06-13 17:41:27


I'm trying to implement concept checking for at least parts of the
boost::fusion library. My motivations are several:

a) I'm interested in making another library/program based on fusion and I
believe that having implemented concepts will make this job easier.

b) I'm interested in the concept checking concept and this is way to
pracitice.

Attached is the current state of my efforts. I have a few problems with
this. I think most of these are specific to fusion but maybe not.

a)
line 29 of test_misc.cpp invokes concept checking on a fusion vector.

lines 28 & 29 of fusion/concepts.hpp are intended to verify that
result_of::next<I> have been defined for the for the forward iterator
associated with the fusion vector. The BOOST_CONCEPT_ASSERT fails with
element 6 from the sequence.

I conclude that the recurrsive invocation of concept checking on the result
of next<I> is crapping out at the end of the sequence. This makes sense in
a practical way - BUT it would voilate the requirements on the return type
from result_of::end<vector>. Sooooo

i) am I right about this?
ii) if so how should it be addressed? fixing the concept implementation
(how?) would "hide" the violation. Seems to be that the documentation on
forward sequence/iterator should be tweaked and my concept checking code
should be fixed up to match. Any thoughts on this?

b)
lines 34-38 illustrate a different problem. I can't figure out what
distance(i,j) is supposed to return. I would think that
result_of::distance(i, j) should be a signed integer of some sort. So I'm
not understanding why this assertion traps. I not sure if it's a side
effect of the problem cited in a) above.

c)
In another file not included here (test_concepts.hpp). I've attempted to
implement archtypes for these types. I managed to do it, but I'm not all
that confident that i did it right. After doing this, I came to understand
the fusion extension mechanism. I could re-implement the archtypes with
this and I'm confident that it would be "correct" BUT I'm wonder if this
just wouldn't be a circular conclusion. That is would doing this really be
testing the concepts or would generating archetypes in this way just
guarentee that things were in some sense internally consistent but not
necessarily reflection the concepts as stated in the documentation.

Any comments/help would be appreciated.

Robert Ramey

begin 666 concepts.hpp
M(VEF;F1E9B!?0T].0T505%-?#0HC9&5F:6YE(%]#3TY#15!44U\-"@T*+R\@
M35,@8V]M<&%T:6)L92!C;VUP:6QE<G,@<W5P<&]R=" C<')A9VUA(&]N8V4-
M"B-I9B!D969I;F5D*%]-4T-?5D52*2 F)B H7TU30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7!L871E(#QT>7!E;F%M92!4/@T*(" @('9O:60@<V%M95]T>7!E*%0_at_8V]N
M<W0F+"!4(&-O;G-T)BD[#0I].PT*#0IT96UP;&%T92 \='EP96YA;64_at_4SX-
M"G-T<G5C="!&;W)W87)D4V5Q=65N8V4@>PT*<'5B;&EC._at_T*(" @($)/3U-4
M7T-/3D-%4%1?55-!1T4H1F]R=V%R9%-E<75E;F-E*0T*(" @('L-"B @(" @
M(" @+R\@=F5R:69Y('1H92!T:&4_at_9F]L;&]W:6YG(&5X:7-T#0H@(" @(" @
M('1Y<&5D968@='EP96YA;64@<F5S=6QT7V]F.CIB96=I;CQ3/CHZ='EP92!T
M,3L-"B @(" @(" @0D]/4U1?0T].0T505%]!4U-%4E0H*"!&;W)W87)D271E
M<F%T;W(\=#$^("DI.PT*(" @(" @("!T,2!X,2 ](&)E9VEN*',I.PT*(" @
M(" @("!T>7!E9&5F('1Y<&5N86UE(')E<W5L=%]O9CHZ96YD/%,^.CIT>7!E
M('0R.PT*+R\@(" @(" @($)/3U-47T-/3D-%4%1?05-315)4*"@@1F]R=V%R
M9$ET97)A=&]R/'0R/B I*3L-"B @(" @(" @=#(@>#(@/2!E;F0H<RD[#0H@
M(" @(" @('1Y<&5D968@='EP96YA;64@<F5S=6QT7V]F.CIS:7IE/%,^.CIT
M>7!E('0S.PT*(" @(" @("!T,R!X,R ]('-I>F4H<RD[#0H@(" @(" @('1Y
M<&5D968@='EP96YA;64@<F5S=6QT7V]F.CIE;7!T>3Q3/CHZ='EP92!T-#L-
M"B @(" @(" @=#0@>#0@/2!E;7!T>2AS*3L-"B @(" @(" @='EP961E9B!T
M>7!E;F%M92!R97-U;'1?;V8Z.F9R;VYT/%,^.CIT>7!E('0U.PT*(" @(" @
M("!T-2!X-2 ](&9R;VYT*',I.PT*(" @('T-"@T*<')I=F%T93H-"B @("!3
M(',[#0H-"B @(" O+R!4>7!E(&1E9'5C=&EO;B!W:6QL(&9A:6P@=6YL97-S
M('1H92!A<F=U;65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[
M#0IU<VEN9R!B;V]S=#HZ;7!L.CIN;W1?.PT*=7-I;F<@8F]O<W0Z.FES7V-L
M87-S.PT*=7-I;F<@;F%M97-P86-E(&)O;W-T.CIF=7-I;VX[#0H-"G1Y<&5D
M968@=F5C=&]R/'-T9#HZ<W1R:6YG+"!C:&%R+"!L;VYG+"!B;V]L+"!D;W5B
M;&4^('9E8W1O<E]T>7!E.PT*='EP961E9B!R97-U;'1?;V8Z.F)E9VEN/'9E
M8W1O<E]T>7!E/CHZ='EP92!V96-T;W)?='EP95]I=&5R871O<CL@#0IT>7!E
M9&5F(&9I;'1E<E]V:65W/'9E8W1O<E]T>7!E(&-O;G-T+"!N;W1?/&ES7V-L
M87-S/%\^(#X@/B!V:65W7W1Y<&4[#0H-"FEN="!M86EN*&EN="!A<F=C+"!C
M:&%R("H_at_87)G=EM=*7L-"B @("!V96-T;W)?='EP92!V*")A+7-T<FEN9R(L
M("= )RP_at_.3@W-C4T+"!T<G5E+" V+C8I.PT*(" @('9I97=?='EP92!V:65W
M*'8I.PT*(" @('-T9#HZ8V]U=" \/"!V:65W(#P\('-T9#HZ96YD;#L-"GT-
M"@T*#0HC:6YC;'5D92 B9G5S:6]N+V-O;F-E<'1S+FAP<"(-"B-I;F-L=61E
M(")S8VAE;6$N:'!P(@T*#0I"3T]35%]#3TY#15!47T%34T525"@H(&)O;W-T
M.CIF=7-I;VXZ.D9O<G=A<F1397%U96YC93QV96-T;W)?='EP93X@*2D[#0I"
M3T]35%]#3TY#15!47T%34T525"@H(&)O;W-T.CIF=7-I;VXZ.D9O<G=A<F13
897%U96YC93QV:65W7W1Y<&4^("DI.PT*
`
end


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk