
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 H7TU30U]615(@/CT@,3 R,"D- M"B,@<')A9VUA(&]N8V4-"B-E;F1I9@T*#0H-"B-I;F-L=61E(#QB;V]S="]C M;VYC97!T+V%S<V5R="YH<' ^#0HC:6YC;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4\22 L2CXZ.G1Y<&4@=#4[#0H@(" @ M(" @('1Y<&5D968@='EP96YA;64@8F]O<W0Z.F9U<VEO;CHZ<F5S=6QT7V]F M.CID97)E9CQ)/CHZ='EP92!T-CL-"B @(" @(" @='EP961E9B!T>7!E;F%M M92!B;V]S=#HZ9G5S:6]N.CIR97-U;'1?;V8Z.G9A;'5E7V]F/$D^.CIT>7!E M('0W.PT*+R\@(" @(" @('0U('@@/2!D:7-T86YC92AI+"!J*3L@#0HO+R @ M(" @(" @0D]/4U1?0T].0T505%]!4U-%4E0H* T*+R\@(" @(" @(" @("!B M;V]S=#HZ4VEG;F5D26YT96=E<CQT>7!E;F%M92!B;V]S=#HZ9G5S:6]N.CIR M97-U;'1?;V8Z.F1I<W1A;F-E/$D@+$H^.CIT>7!E/@T*+R\@(" @(" @("DI M.PT*(" @(" @("!S86UE7W1Y<&4H:2 ]/2!J+"!B*3L-"B @(" @(" @<V%M M95]T>7!E*&D@(3T@:BP@8BD[#0H@(" @(" @('-A;65?='EP92AD97)E9BAI M*2P@=BD[.PT*(" @(" @("!S86UE7W1Y<&4H*FDL('8I.PT*(" @('T-"B @ M(" -"G!R:79A=&4Z#0H@(" @22!I+"!J.PT*(" @(&)O;VP@8CL-"B @("!T M>7!E;F%M92!B;V]S=#HZ9G5S:6]N.CIR97-U;'1?;V8Z.G9A;'5E7V]F/$D^ M.CIT>7!E('8[#0H@(" @='EP961E9B!B;V]S=#HZ;7!L.CII;G1?/# ^.CIT M>7!E($T[#0H-"B @(" O+R!4>7!E(&1E9'5C=&EO;B!W:6QL(&9A:6P@=6YL M97-S('1H92!A<F=U;65N=',@:&%V92!T:&4@<V%M92!T>7!E+@T*(" @('1E M;7!L871E(#QT>7!E;F%M92!4/@T*(" @('9O:60@<V%M95]T>7!E*%0@8V]N M<W0F+"!4(&-O;G-T)BD[#0I].PT*#0IT96UP;&%T92 \='EP96YA;64@4SX- M"G-T<G5C="!&;W)W87)D4V5Q=65N8V4@>PT*<'5B;&EC.@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@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;65N=',@:&%V92!T:&4@<V%M92!T>7!E+@T*(" @('1E;7!L M871E(#QT>7!E;F%M92!4/@T*(" @('9O:60@<V%M95]T>7!E*%0@8V]N<W0F M+"!4(&-O;G-T)BD[#0I].PT*#0I]("\O(&9U<VEO;@T*?2 O+R!B;V]S= T* M#0HC:6YC;'5D92 \8F]O<W0O9G5S:6]N+VET97)A=&]R+VME>5]O9BYH<' ^ M#0HC:6YC;'5D92 \8F]O<W0O9G5S:6]N+VET97)A=&]R+W9A;'5E7V]F7V1A M=&$N:'!P/@T*(VEN8VQU9&4@/&)O;W-T+V9U<VEO;B]I=&5R871O<B]D97)E M9E]D871A+FAP<#X-"@T*;F%M97-P86-E(&)O;W-T('L-"FYA;65S<&%C92!F M=7-I;VX@>PT*#0IT96UP;&%T92 \='EP96YA;64@23X-"G-T<G5C="!!<W-O M8VEA=&EV94ET97)A=&]R(#H-"B @("!&;W)W87)D271E<F%T;W(\23X-"GL- M"G!U8FQI8SH-"B @("!"3T]35%]#3TY#15!47U5304=%*$%S<V]C:6%T:79E M271E<F%T;W(I#0H@(" @>PT*(" @(" @(" O+R!V97)I9GD@=&AE('1H92!F M;VQL;W=I;F<@97AI<W0-"B @(" @(" @='EP961E9B!T>7!E;F%M92!B;V]S M=#HZ9G5S:6]N.CIR97-U;'1?;V8Z.FME>5]O9CQ)/CHZ='EP92!T,3L-"B @ M(" @(" @='EP961E9B!T>7!E;F%M92!B;V]S=#HZ9G5S:6]N.CIR97-U;'1? M;V8Z.G9A;'5E7V]F7V1A=&$\23XZ.G1Y<&4@=#([#0H@(" @(" @('1Y<&5D M968@='EP96YA;64@8F]O<W0Z.F9U<VEO;CHZ<F5S=6QT7V]F.CID97)E9E]D M871A/$D^.CIT>7!E('0S.PT*(" @(" @("!S86UE7W1Y<&4H9&5R969?9&%T M82AI*2P@8F]O<W0Z.F9U<VEO;CHZ<F5S=6QT7V]F.CID97)E9E]D871A/$D^ M.CIT>7!E*3L-"B @("!]#0H@(" @#0H@<')I=F%T93H-"B @("!)(&D[#0H@ M(" @+R\@5'EP92!D961U8W1I;VX@=VEL;"!F86EL('5N;&5S<R!T:&4@87)G M=6UE;G1S(&AA=F4@=&AE('-A;64@='EP92X-"B @("!T96UP;&%T92 \='EP M96YA;64@5#X-"B @("!V;VED('-A;65?='EP92A4(&-O;G-T)B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?;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@87)G=EM=*7L-"B @("!V96-T;W)?='EP92!V*")A+7-T<FEN9R(L M("= )RP@.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

On 13/06/11 16:41, Robert Ramey wrote:
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.
Are you lookign for fusion sequence concept ? If yes , we did this : https://github.com/MetaScale/nt2/tree/master/modules/sdk/include/nt2/sdk/con...

On 6/14/2011 5:44 AM, Joel falcou wrote:
On 13/06/11 16:41, Robert Ramey wrote:
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.
Are you lookign for fusion sequence concept ? If yes , we did this :
https://github.com/MetaScale/nt2/tree/master/modules/sdk/include/nt2/sdk/con...
Joel, I'd welcome a patch. This looks good! Regards, -- Joel de Guzman http://www.boostpro.com http://boost-spirit.com

On 6/14/2011 8:20 AM, Joel falcou wrote:
On 13/06/11 18:35, Joel de Guzman wrote:
Joel, I'd welcome a patch. This looks good!
Anything in nt2 is Boost.Licensed, just copy the files over :p
Thanks, Joel! -- Joel de Guzman http://www.boostpro.com http://boost-spirit.com

Joel falcou wrote:
On 13/06/11 16:41, Robert Ramey wrote:
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.
Are you lookign for fusion sequence concept ? If yes , we did this :
https://github.com/MetaScale/nt2/tree/master/modules/sdk/include/nt2/sdk/con...
This looks similar to my attempt so I guess I'm on the right track. Thanks for this. Any thoughts on my other questions? specifically in regards to fusion::ForwardIterator (recusion problem) and Archtypes? Robert Ramey
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On Mon, Jun 13, 2011 at 2:41 PM, Robert Ramey <ramey@rrsd.com> wrote:
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.
[...]
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.
Just quickly addressing this and only this, without looking at the referenced lines: I would think distance(i,j) would be a Boost.MPL integral constant. - Jeff

Jeffrey Lee Hellrung, Jr. wrote:
On Mon, Jun 13, 2011 at 2:41 PM, Robert Ramey <ramey@rrsd.com> wrote:
Just quickly addressing this and only this, without looking at the referenced lines: I would think distance(i,j) would be a Boost.MPL integral constant.
Actually, I managed to find this one and you are right. The documentation was/is confusing to me on this point.
- Jeff _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On 6/14/2011 5:41 AM, Robert Ramey wrote:
begin 666 concepts.hpp M(VEF;F1E9B!?0T].0T505%-?#0HC9&5F:6YE(%]#3TY#15!44U\-"@T*+R\@like?
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 H7TU30U]615(@/CT@,3 R,"D-
[snip]
end
begin 666 test_misc.cpp M(VEN8VQU9&4@/'-T<FEN9SX-"B-I;F-L=61E(#QI;W-T<F5A;3X-"@T*(VEN M8VQU9&4@/&)O;W-T+V9U<VEO;B]C;VYT86EN97(O=F5C=&]R+FAP<#X-"B-I M;F-L=61E(#QB;V]S="]F=7-I;VXO=FEE=R]F:6QT97)?=FEE=RYH<' ^#0HC
[snip] Robert, I can't read the code. Encrypted? Regards, -- Joel de Guzman http://www.boostpro.com http://boost-spirit.com

Joel de Guzman wrote:
On 6/14/2011 5:41 AM, Robert Ramey wrote:
begin 666 concepts.hpp M(VEF;F1E9B!?0T].0T505%-?#0HC9&5F:6YE(%]#3TY#15!44U\-"@T*+R\@like?
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 H7TU30U]615(@/CT@,3 R,"D-
[snip]
end
begin 666 test_misc.cpp M(VEN8VQU9&4@/'-T<FEN9SX-"B-I;F-L=61E(#QI;W-T<F5A;3X-"@T*(VEN M8VQU9&4@/&)O;W-T+V9U<VEO;B]C;VYT86EN97(O=F5C=&]R+FAP<#X-"B-I M;F-L=61E(#QB;V]S="]F=7-I;VXO=FEE=R]F:6QT97)?=FEE=RYH<' ^#0HC
[snip]
Robert, I can't read the code. Encrypted?
Regards,

Joel de Guzman wrote:
On 6/14/2011 5:41 AM, Robert Ramey wrote:
Robert, I can't read the code. Encrypted?
/////////////////////////////////////////// // fusion/concepts.hpp #ifndef _FUSION_CONCEPTS_ #define _FUSION_CONCEPTS_ // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include <boost/concept/assert.hpp> #include <boost/concept_check.hpp> #include <boost/fusion/iterator.hpp> #include <boost/fusion/sequence.hpp> #include <boost/mpl/print.hpp> namespace boost { namespace fusion { template <typename I> struct ForwardIterator : boost::EqualityComparable<I>, boost::CopyConstructible<I> { public: BOOST_CONCEPT_USAGE(ForwardIterator) { typedef I J; // verify the the following exist typedef typename boost::fusion::result_of::next<I>::type t1; // BOOST_CONCEPT_ASSERT(( ForwardIterator<t1> )); typedef typename boost::fusion::result_of::equal_to<I, J>::type t2; typedef typename boost::fusion::result_of::advance_c<I,0>::type t3; typedef typename boost::fusion::result_of::advance<I ,M>::type t4; typedef typename boost::fusion::result_of::distance<I ,J>::type t5; // distance should be convertable to a signed int int x = boost::fusion::distance(i, j); typedef typename boost::fusion::result_of::deref<I>::type t6; typedef typename boost::fusion::result_of::value_of<I>::type t7; same_type(i == j, b); same_type(i != j, b); same_type(deref(i), v);; same_type(*i, v); } private: I i, j; bool b; typename boost::fusion::result_of::value_of<I>::type v; typedef boost::mpl::int_<0>::type M; // Type deduction will fail unless the arguments have the same type. template <typename T> void same_type(T const&, T const&); }; template <typename S> struct ForwardSequence { public: BOOST_CONCEPT_USAGE(ForwardSequence) { // verify the the following exist typedef typename result_of::begin<S>::type t1; BOOST_CONCEPT_ASSERT(( ForwardIterator<t1> )); t1 x1 = begin(s); typedef typename result_of::end<S>::type t2; BOOST_CONCEPT_ASSERT(( ForwardIterator<t2> )); t2 x2 = end(s); typedef typename result_of::size<S>::type t3; t3 x3 = size(s); typedef typename result_of::empty<S>::type t4; t4 x4 = empty(s); typedef typename result_of::front<S>::type t5; t5 x5 = front(s); } private: S s; // Type deduction will fail unless the arguments have the same type. template <typename T> void same_type(T const&, T const&); }; } // fusion } // boost #include <boost/fusion/iterator/key_of.hpp> #include <boost/fusion/iterator/value_of_data.hpp> #include <boost/fusion/iterator/deref_data.hpp> namespace boost { namespace fusion { template <typename I> struct AssociativeIterator : ForwardIterator<I> { public: BOOST_CONCEPT_USAGE(AssociativeIterator) { // verify the the following exist typedef typename boost::fusion::result_of::key_of<I>::type t1; typedef typename boost::fusion::result_of::value_of_data<I>::type t2; typedef typename boost::fusion::result_of::deref_data<I>::type t3; same_type(deref_data(i), boost::fusion::result_of::deref_data<I>::type); } private: I i; // Type deduction will fail unless the arguments have the same type. template <typename T> void same_type(T const&, T const&); }; } // fusion } // boost /* Bidirectional Iterator Random Access Iterator Associative Iterator Forward Sequence Bidirectional Sequence Random Access Sequence Associative Sequence Callable Object Regular Callable Object Deferred Callable Object Polymorphic Function Object */ #endif // _FUSION_CONCEPTS_ /////////////////////////////////////////////// // test_concepts.cpp #include <boost/concept/assert.hpp> #include "concepts.hpp" namespace boost { namespace fusion{ struct ForwardIteratorArchtype { bool operator==(const ForwardIteratorArchtype &) const; bool operator!=(const ForwardIteratorArchtype &) const; int operator*(); }; namespace traits { template <> struct category_of<ForwardIteratorArchtype> { typedef forward_traversal_tag type; }; } namespace result_of { template<> struct next<ForwardIteratorArchtype> { typedef ForwardIteratorArchtype type; }; template<typename I> struct equal_to<ForwardIteratorArchtype, I> { typedef typename boost::is_same<I, ForwardIteratorArchtype>::type type; }; template<int N> struct advance_c<ForwardIteratorArchtype, N> { typedef ForwardIteratorArchtype type; }; template<typename N> struct advance<ForwardIteratorArchtype, N> { typedef ForwardIteratorArchtype type; }; template<> struct distance<ForwardIteratorArchtype, ForwardIteratorArchtype> { typedef int type; }; template<> struct deref<ForwardIteratorArchtype> { typedef int type; }; template<> struct value_of<ForwardIteratorArchtype> { typedef int type; }; } // result_of result_of::next<ForwardIteratorArchtype>::type next(ForwardIteratorArchtype &); template <int N> typename result_of::advance_c<ForwardIteratorArchtype, N>::type const advance_c(ForwardIteratorArchtype const& i); void f(){ ForwardIteratorArchtype i; advance_c<1>(i); } template <typename M> typename result_of::advance<ForwardIteratorArchtype, M>::type const advance(ForwardIteratorArchtype const & i); void g(){ ForwardIteratorArchtype i; advance<boost::mpl::int_<1> >(i); } result_of::deref<ForwardIteratorArchtype>::type deref(ForwardIteratorArchtype const& i); result_of::deref<ForwardIteratorArchtype>::type value_of(ForwardIteratorArchtype const& i); result_of::distance<ForwardIteratorArchtype, ForwardIteratorArchtype>::type distance(ForwardIteratorArchtype const& i, ForwardIteratorArchtype const& j); } // fusion } // boost BOOST_CONCEPT_ASSERT(( boost::fusion::ForwardIterator< boost::fusion::ForwardIteratorArchtype > )); namespace boost { namespace fusion{ struct AssociativeIteratorArchtype : ForwardIteratorArchtype { //int operator*(); }; namespace traits { template <> struct category_of<AssociativeIteratorArchtype> { typedef associative_tag type; }; } namespace result_of { template<> struct boost::fusion::result_of::key_of<AssociativeIteratorArchtype> { typedef AssociativeIteratorArchtype type; }; template<> struct value_of_data<AssociativeIteratorArchtype> { typedef int type; }; template<> struct deref_data<AssociativeIteratorArchtype> { typedef int type; }; } // result_of result_of::deref_data<AssociativeIteratorArchtype>::type deref_data(AssociativeIteratorArchtype &); } // fusion } // boost BOOST_CONCEPT_ASSERT(( boost::fusion::AssociativeIterator< boost::fusion::AssociativeIteratorArchtype > ));
Regards,

Robert Ramey wrote:
[snip]
template <typename S> struct ForwardSequence { public: BOOST_CONCEPT_USAGE(ForwardSequence) { [snip] }
private: S s;
FYI, unused:
// Type deduction will fail unless the arguments have the same type. template <typename T> void same_type(T const&, T const&); };
[snip]
template <typename I> struct AssociativeIterator : ForwardIterator<I> { public: BOOST_CONCEPT_USAGE(AssociativeIterator) { // verify the the following exist typedef typename boost::fusion::result_of::key_of<I>::type t1; typedef typename boost::fusion::result_of::value_of_data<I>::type t2; typedef typename boost::fusion::result_of::deref_data<I>::type t3; same_type(deref_data(i), boost::fusion::result_of::deref_data<I>::type);
Shouldn't that last statement have been the following? t3 dd; same_type(deref_data(i), dd);
}
private: I i; // Type deduction will fail unless the arguments have the same type. template <typename T> void same_type(T const&, T const&); };
_____ Rob Stewart robert.stewart@sig.com Software Engineer using std::disclaimer; Dev Tools & Components Susquehanna International Group, LLP http://www.sig.com IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
participants (5)
-
Jeffrey Lee Hellrung, Jr.
-
Joel de Guzman
-
Joel falcou
-
Robert Ramey
-
Stewart, Robert