Opened 13 years ago

Closed 7 years ago

#3358 closed Bugs (fixed)

return type of functions incorrect

Reported by: anonymous Owned by: Joel de Guzman
Milestone: Boost 1.40.0 Component: fusion
Version: Boost 1.38.0 Severity: Problem
Keywords: const return Cc:

Description

maybe only documented incorrectly, but given the error messages it still takes a few years to figure that out.

e.g. push_back, documented as: typename result_of::push_back<Sequence, T>::type push_back(

Sequence const& seq, T const& t);

when it's actually typename result_of::push_back<Sequence const, T>::type

push_back(Sequence const& seq, T const& x)

note the const. I'm not sure why the const is there, but if it is really intended that: result_of::push_back<seq_t,int>::type res=push_back(seq,4); should result in an error, this should be a major part of the documentation.

Change History (4)

comment:1 by Steven Watanabe, 13 years ago

Actually, I think it would be better if fusion::push_back were overloaded to allow either const or non-const arguments, like

    template <typename Sequence, typename T>
    inline typename result_of::push_back<Sequence, T>::type
    push_back(Sequence & seq, T const& x);

    template <typename Sequence, typename T>
    inline typename result_of::push_back<Sequence const, T>::type
    push_back(Sequence const& seq, T const& x);

Regardless, result_of::push_back ought to work correctly for non-const arguments. If push_back always adds const, then so should result_of::push_back.

in reply to:  1 comment:2 by Kohei Takahashi <flast@…>, 7 years ago

Fixed by https://github.com/boostorg/fusion/pull/106 .

Replying to steven_watanabe:

Actually, I think it would be better if fusion::push_back were overloaded to allow either const or non-const arguments, like

    template <typename Sequence, typename T>
    inline typename result_of::push_back<Sequence, T>::type
    push_back(Sequence & seq, T const& x);

    template <typename Sequence, typename T>
    inline typename result_of::push_back<Sequence const, T>::type
    push_back(Sequence const& seq, T const& x);

It will be handled in #3954.

comment:3 by Kohei Takahashi <flast@…>, 7 years ago

Joel, could you close this ticket?

comment:4 by Joel de Guzman, 7 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.