4 ms·
And I thought auto was the best thing ever to happen to C++? Especially when working with STL.
by maxxxxx 9y ago
And I thought auto was the best thing ever to happen to C++? Especially when working with STL.
- gambiting 9y agoMy problem with auto is that Visual Studio loses all ability to predict code when you use it. So when I do Type object and then do object. I get all the methods/members available for that Type. But if I use auto, VS is either can't recommend anything or recommends the wrong set of methods entirely. It really slows me down as a programmer and I hate using it for that reason.
- maxxxxx 9y agoThat seems to be a VS problem. They could easily infer the type and give you correct auto complete. It works perfectly fine in C# when you see var.
- deleted 9y ago[deleted]
- EpicEng 9y agoVS handles it just fine, this is something specific to the parent.
- stefantheard 9y agoDefinitely shouldn't be restricting how you code based on your IDE. If VS can't handle auto, either update for a fix or switch to CLion, it works just fine there.
- gambiting 9y agoIf the environments I code for only use VS(Xbox One/PS4) then I think it's fair to code for that IDE. We use Visual Assist at work and auto + hugely templated classes are a complete fail, it just gets no predictive text at all.
- zvrba 9y agoIt worked fine in VS2015 and works fine in VS2017. It doesn't work in cases where it cannot work, as in ``` template<typename T> void f(const T& t) { auto val = t.some_method(); } ``` and here it cannot work because T can be an arbitrary type and there's simply not enough info for intellisense to work and suggest members on val.
- trendia 9y agoQt Creator handles this problem differently. If you call f<int>(0) and f<uchar>(0) within your code, then the Clang code model will process both in the background, check for any syntax errors, and show an error if either one fails. It's very useful while coding because you don't have to wait until compilation time to see an error, and it's a feature I wish VS would implement.
- steveklabnik 9y agoMeta: HN doesn't support markdown, use two spaces to get code formatting. Full docs here: https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc
- criddell 9y ago> My problem with auto is that Visual Studio loses all ability to predict code when you use it. That sounds more like your problem with Visual Studio.
- cjensen 9y agoVisual Studio is fine with auto. Are you using a plugin like Visual Assist? It's a great plugin, but it does have issues where it behaves as you describe.
- gambiting 9y agoYeah, we use Visual Assist here, I suspect it's the reason behind this issue but then again it's a lot better than Intellisense in day-to-day use so.....