top | item 46271018

(no title)

flakes | 2 months ago

Auto has really made c++ unapproachable to me. It's hard enough to reason about anything templated, and now I frequently see code where every method returns auto. How is any one supposed to do a code review without loading the patch into their IDE?

discuss

order

OneDeuxTriSeiGo|2 months ago

I'd suppose this really depends on how you are developing your codebase but most code should probably be using a trailing return type or using an auto (or template) return type with a concept/requires constraint on the return type.

For any seriously templated or metaprogrammed code nowadays a concept/requires is going to make it a lot more obvious what your code is actually doing and give you actually useful errors in the event someone is misusing your code.

jjmarr|2 months ago

I don't understand why anyone would use auto and a trailing return type for their functions. The syntax is annoying and breaks too much precedent.

Traubenfuchs|2 months ago

Same in Java and Kotlin, but then again, the majority of people who write code wouldn't understand what I mean when I say "whether a collection is returned as List or Set is an important part of the API 'contract'".

themafia|2 months ago

The pain of lisp without any of the joy.