Does anyone actually use stream extraction operators?

后端 未结 7 2105
余生分开走
余生分开走 2020-12-25 14:26

I\'ve written tons of operator<<(std::ostream &, const T &) functions -- they\'re incredibly useful.

I\'ve never written an operator

相关标签:
7条回答
  • 2020-12-25 15:27

    I made heavy use of operator<< to assemble lists of sort instructions, fields into database views etc. in my OOFILE database API.

    For some reason, a large number of users found it intuitive to use the operator>> to append a sort field which was a reverse sort. I don't know who suggested it in the first place but it appealed to enough people that it made it in the API.

    eg:

    dbSorter arcSort;  // declare a sorter
    arcSort << reverse(Date) << FileName; // "normal" way to specify two sort fields
    arcSort >> Date << FileName;  // shorthand way that evolved to specify 
    

    We also made conventional use of operator>> to parse an entire dbTable from a stream.

    0 讨论(0)
提交回复
热议问题