• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 08:53
CET 14:53
KST 22:53
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation13Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
Zerg is losing its identity in StarCraft 2 [TLMC] Fall/Winter 2025 Ladder Map Rotation Mech is the composition that needs teleportation t RotterdaM "Serral is the GOAT, and it's not close" RSL Season 3 - RO16 Groups C & D Preview
Tourneys
RSL Revival: Season 3 Sparkling Tuna Cup - Weekly Open Tournament Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
FlaSh on: Biggest Problem With SnOw's Playstyle BGH Auto Balance -> http://bghmmr.eu/ What happened to TvZ on Retro? SnOw's ASL S20 Finals Review BW General Discussion
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET
Strategy
PvZ map balance Current Meta Simple Questions, Simple Answers How to stay on top of macro?
Other Games
General Games
Clair Obscur - Expedition 33 Should offensive tower rushing be viable in RTS games? Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread Artificial Intelligence Thread Canadian Politics Mega-thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2241 users

The Big Programming Thread - Page 724

Forum Index > General Forum
Post a Reply
Prev 1 722 723 724 725 726 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-27 21:04:08
April 27 2016 20:34 GMT
#14461
On April 28 2016 05:22 Khalum wrote:

[..]
int err;
[..]


brrrrrr......


int err;
struct foo *a = alloc_foo();
if (!a) return fail(a, err);


What will this return? Same question for the goto implementation.


But you should be calling fail with a null pointer and whatever value was in memory when err was initialized.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Khalum
Profile Joined September 2010
Austria831 Posts
April 27 2016 20:46 GMT
#14462
Why try to write fail-safe code and then not even initialize 'err'?
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-27 21:15:16
April 27 2016 21:01 GMT
#14463
On April 28 2016 05:46 Khalum wrote:
Why try to write fail-safe code and then not even initialize 'err'?


I think that was an oversight by the quick code writing. In the second function you're passing the int err to the fail function, but you don't do anything with it so it might as well not be a parameter and just have void return.

The real argument is whether or not goto is more valuable than not having the overhead of an additional function call. When you're talking about low level kernel code written 30 years ago the additional overhead would be a problem.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Khalum
Profile Joined September 2010
Austria831 Posts
April 27 2016 21:16 GMT
#14464
I realize that I kinda derailed the discussion but I always have this 'brrrrrrrrr' feeling when I see things like that. Talking about higher level things is fine and great but people should start initializing their variables first.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
April 28 2016 05:19 GMT
#14465
On April 28 2016 04:39 Acrofales wrote:
Show nested quote +
On April 28 2016 04:33 Cyx. wrote:
On April 27 2016 16:49 Morfildur wrote:
Well, it was written when disk space actually still mattered. Saving 500 bytes on variable names made all the difference.

That said, someone should really at least fix the variable names to something easier to understand and add a few braces where they've been omitted.

Strongly disagree... don't touch code that works Among the worst sins you can commit as a programmer is breaking things for the sake of pretty code.
On April 27 2016 16:49 Morfildur wrote:
The gotos are probably there to stay since C that close to the system often has those for performance reasons. I'd expect a modern compiler to optimize better without them, but Linux system and kernel programmers, do love their gotos since back in the day you could save a few processor cycles with them.

All in all, it's another example for why I don't engage in open source projects. All the projects I checked out have too many programmers with too little real world experience that write "clever" instead of good code, legacy code that the project creator wrote half-drunk 10 years ago that no one dares to touch for fear of breaking everything and too many people that have a hard-on for micro-optimizations while writing slow algorithms.

Also somewhat disagree that the gotos are for performance reasons. They're significantly more readable than the alternative. Using gotos properly in C can save you a ton of duplicated cleanup code, which is why those C programmers (Linux devs, GCC devs, BSD devs...) like them so much.

eg:


int func() {
int err;
struct foo *a = alloc_foo();
if (!a) return;

err = init_foo(a);
if (err) {
free_foo(a);
return err;
}

err = do_something_with_foo(a);
if (err) {
free_foo(a);
return err;
}

return 0;
}


vs.


int func() {
int err;
struct foo *a = alloc_foo();
if (!a) goto fail;

err = init_foo(a);
if (err) goto fail;

err = do_something_with_foo(a);
if (err) goto fail;

return 0;

fail:
free_foo(a);
return err;
}


I mean, maybe a pretty trivial example, but there are places in the Linux kernel where this style of error handling reduces code duplication by a really significant amount.


Can do that just fine without gotos.


int func() {
int err;
struct foo *a = alloc_foo();
if (!a) return fail(a, err);

err = init_foo(a);
if (err) return fail(a, err);

err = do_something_with_foo(a);
if (err) return fail(a, err);

return 0;
}

int fail(foo *a, int err) {
free_foo(a);
return err;
}


And the advantage of this is that your code will never ever enter the fail code by mistake because you forgot a corner case in which there is no return statement above your label.




Yup, pretty much. In 99.9% of the situations gotos can be completely removed by wrapping the code in a function and returning from it. If you define it as inline, it probably even ends up as exactly the same assembly code. It's my observation though that many C programmers hate having extra functions for some reason. Probably has something to do with having to actually think of a proper function name instead of being able to use b2, b5, x or such as a function name.
Artesimo
Profile Joined February 2015
Germany563 Posts
April 28 2016 12:28 GMT
#14466
Hey guys, I run into some problems that I cant figure out. When trying to build/buld&clean, netbeans tells me:
Server.cpp:12:6: error: redefinition of ‘void Server::session(socket_ptr)’
In file included from Server.cpp:1:0:[pointing to session in Server.cpp]
Server.h:30:10: error: ‘void Server::session(socket_ptr)’ previously defined here[pointing to the session-definition in Server.h]

I am not sure what the problem is since I don't redefine session. After building, Netbeans also marks "#Include "Server.h"" in Server.cpp as an error, while also stating "In file included from --- (Alt-Enter shows hints)". If I press alt enter, nothing happens.

Here is my code so far:
Server.h

#ifndef SERVER_H
#define SERVER_H
#include <cstdlib>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/smart_ptr.hpp>
#include <boost/asio.hpp>
#include <boost/thread/thread.hpp>
#include <string>
#include <sstream>
#include <vector>

using boost::asio::ip::tcp;
typedef boost::shared_ptr<tcp::socket> socket_ptr;

class Server {

private:
int port;
std::string messageTermiantor;
const int max_length = 1024;

public:
Server();
Server(const Server& orig);
virtual ~Server();
void session(socket_ptr sock){};
std::vector<std::string> split(std::string str, char delimiter) {};
void server(boost::asio::io_service& io_service, short) {};
void loop();


};

#endif /* SERVER_H */


Server.cpp:

#include "Server.h"

Server::Server() {
}

Server::Server(const Server& orig) {
}

Server::~Server() {
}

void Server::session(socket_ptr sock){
};

std::vector<std::string> split(std::string str, char delimiter) {
std::vector<std::string> internal;
std::stringstream ss(str);
std::string tok;

while (getline(ss, tok, delimiter)) {
internal.push_back(tok);
}
return internal;
}
SMaD
Profile Joined September 2010
Spain137 Posts
Last Edited: 2016-04-28 13:02:11
April 28 2016 12:47 GMT
#14467
I'd suggest removing brackets "{ }" from the Server.h as I am pretty sure Netbeans interprets it as a "first" definition of your session function.
Artesimo
Profile Joined February 2015
Germany563 Posts
April 28 2016 12:48 GMT
#14468
I am stupid
tofucake
Profile Blog Joined October 2009
Hyrule19153 Posts
April 28 2016 15:23 GMT
#14469
no, netbeans is stupid
Liquipediaasante sana squash banana
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-04-28 18:09:39
April 28 2016 18:09 GMT
#14470
Isn't that a standard error?

Also, use CMake :3
There is no one like you in the universe.
Artesimo
Profile Joined February 2015
Germany563 Posts
April 28 2016 21:04 GMT
#14471
On April 29 2016 03:09 Blisse wrote:
Isn't that a standard error?

Also, use CMake :3


I am too stupid to properly set up a makefile and cant install anything on the lab-pcs unfortunately.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
Last Edited: 2016-04-29 08:09:23
April 29 2016 08:08 GMT
#14472
On April 27 2016 23:42 WarSame wrote:
Show nested quote +
On April 27 2016 18:41 Wrath wrote:
On April 27 2016 10:43 WarSame wrote:
Folks, looking for a bit of help with mean.io. I dled and installed node, mongodb and git. I then init a directory and run npm install inside of it. I then run gulp to start the server. This throws errors that I'm missing various modules such as 'mongoose', 'async', etc. but these should be installed from the npm install, correct? The exact error is + Show Spoiler +
E:\mean_workspace\monoprobability\node_modules\q\q.js:155
throw e;
^

Error: Cannot find module 'mongoose'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\server\models\user.js:6:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at requireModel (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:116:19)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:21:7
at Array.forEach (native)
at walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:23:7
at Array.forEach (native)
at Object.walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at MeanUserKlass.Module (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:134:14)
at new MeanUserKlass (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:10:10)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:21:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Module.activate (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\dependablelist.js:52:15)



When I tried to start using mean.io on another computer it worked fine so it is almost certainly a problem with my current environment. When I look inside of my root's node_modules folder it is missing both 'async' and 'mongoose'. Are they supposed to be in that folder?


Can't you copy them from the other computer and see if that solves the issue for you?

The other computer is a work computer which disables copying files :/

Show nested quote +
On April 27 2016 19:43 Acrofales wrote:
On April 27 2016 10:43 WarSame wrote:
Folks, looking for a bit of help with mean.io. I dled and installed node, mongodb and git. I then init a directory and run npm install inside of it. I then run gulp to start the server. This throws errors that I'm missing various modules such as 'mongoose', 'async', etc. but these should be installed from the npm install, correct? The exact error is + Show Spoiler +
E:\mean_workspace\monoprobability\node_modules\q\q.js:155
throw e;
^

Error: Cannot find module 'mongoose'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\server\models\user.js:6:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at requireModel (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:116:19)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:21:7
at Array.forEach (native)
at walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:23:7
at Array.forEach (native)
at Object.walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at MeanUserKlass.Module (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:134:14)
at new MeanUserKlass (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:10:10)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:21:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Module.activate (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\dependablelist.js:52:15)



When I tried to start using mean.io on another computer it worked fine so it is almost certainly a problem with my current environment. When I look inside of my root's node_modules folder it is missing both 'async' and 'mongoose'. Are they supposed to be in that folder?


Is your internet stable, and no timeout problems? I've had issues with npm skipping stuff if it cannot get it sufficiently quickly, and then claiming success all the same. rerunning npm install usually works, but sometimes it's really confused and you need to throw away your node_modules and start again. either that, or your package.json is wrong.

Yup, my internet is pretty stable here. I've run the command like 5 times in a row and I've deleted and reinited the app ~5 times too, so that shouldn't be it. My package.json is simply the default mean.io package, so it should be fine.

I know it's a dumb question but... Does your package.json have async and mongoose in dependencies section? The only other thing I can think about is async and mongoose getting deleted from central npm repo. I don't think internet connection creates major issues because I might be having one of the shittiest internet connections in the entire thread and still didn't have any issues with npm claiming success but not downloading dependencies. Regardless, you can run:

npm install --save async mongoose 


and solve your problem that way.
"windows bash is a steaming heap of shit" tofucake
Artesimo
Profile Joined February 2015
Germany563 Posts
Last Edited: 2016-04-29 14:08:36
April 29 2016 10:47 GMT
#14473
I got another problem. I have a hard time understanding boost::bind in combination with a class. I got:

void Server::session(socket_ptr sock){...}


Without having session() as a function of a class, I can use:

boost::thread t(boost::bind(session, sock));


In a class I thought I had to do this:

void Server::server(boost::asio::io_service& io_service, short port) {
.
.
.


boost::thread t(boost::bind(&Server::session, ref(this), _1)(sock));
}


Needless to say, it doesn't work.
Cyx.
Profile Joined November 2010
Canada806 Posts
Last Edited: 2016-04-29 22:21:11
April 29 2016 17:27 GMT
#14474
On April 29 2016 19:47 Artesimo wrote:

void Server::server(boost::asio::io_service& io_service, short port) {
.
.
.


boost::thread t(boost::bind(&Server::session, ref(this), _1)(sock));
}


Needless to say, it doesn't work.

I don't think you need the 'ref(this)' call - the Boost docs seem to imply that you can call that as just

boost::thread t(boost::bind(&Server::session, this, _1)(sock));


Although this raises the question, why bother binding it at all if you immediately call it with 'sock' as an argument?

EDIT: read this again and I'm pretty sure your problem is actually that you're passing the bound function to boost::thread() in the first case, but in the second case you're *calling* the bound function and passing the result. These things are not equivalent:


boost::thread t(boost::bind(&Server::session, this, _1)(sock));
boost::thread t(boost::bind(&Server::session, this, sock));


I think you want the second one, not the first.
Manit0u
Profile Blog Joined August 2004
Poland17433 Posts
Last Edited: 2016-04-29 18:06:30
April 29 2016 17:36 GMT
#14475
On April 29 2016 06:04 Artesimo wrote:
Show nested quote +
On April 29 2016 03:09 Blisse wrote:
Isn't that a standard error?

Also, use CMake :3


I am too stupid to properly set up a makefile and cant install anything on the lab-pcs unfortunately.


You can get away even with simple makefiles for the most part.
Time is precious. Waste it wisely.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 29 2016 22:23 GMT
#14476
Has anyone tried C++11/14 yet? What do you like and what don't you like?
Mr. Wiggles
Profile Blog Joined August 2010
Canada5894 Posts
April 29 2016 22:58 GMT
#14477
On April 30 2016 07:23 Shield wrote:
Has anyone tried C++11/14 yet? What do you like and what don't you like?

I haven't used it too heavily yet outside of some of the quality of life improvements.

I enjoy using the new type inference stuff. For example, auto is very nice and helps with not having to always type out full type names, especially when the type doesn't exactly help with readability.

Range-based iteration is also nice. Compare:

for (std::vector<SomeObj>::iterator it = vec.begin(); it != vec.end(); ++it) {
// Do stuff
}


for (auto &elem : vec) {
// Do stuff
}


I like using lambda functions (closures) as well. When used effectively, they can simplify some code and make it easier to read.

The changes to initialization are a welcome addition also. There's also been some changes introduced that allow you to lean on the compiler a little more, which is nice. For example: constexpr, strongly typed enumerations, etc.

Like I said, I haven't used too many of the more advanced features, but just these ones and a few others result in much cleaner and readable code than before when they're leveraged effectively. Overall, I like the introduced changes.

I'd recommend this book if you'd like to learn more: https://www.amazon.ca/Effective-Modern-Specific-Ways-Improve/dp/1491903996
you gotta dance
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 29 2016 23:05 GMT
#14478
On April 30 2016 07:58 Mr. Wiggles wrote:
Show nested quote +
On April 30 2016 07:23 Shield wrote:
Has anyone tried C++11/14 yet? What do you like and what don't you like?

I haven't used it too heavily yet outside of some of the quality of life improvements.

I enjoy using the new type inference stuff. For example, auto is very nice and helps with not having to always type out full type names, especially when the type doesn't exactly help with readability.

Range-based iteration is also nice. Compare:

for (std::vector<SomeObj>::iterator it = vec.begin(); it != vec.end(); ++it) {
// Do stuff
}


for (auto &elem : vec) {
// Do stuff
}


I like using lambda functions (closures) as well. When used effectively, they can simplify some code and make it easier to read.

The changes to initialization are a welcome addition also. There's also been some changes introduced that allow you to lean on the compiler a little more, which is nice. For example: constexpr, strongly typed enumerations, etc.

Like I said, I haven't used too many of the more advanced features, but just these ones and a few others result in much cleaner and readable code than before when they're leveraged effectively. Overall, I like the introduced changes.

I'd recommend this book if you'd like to learn more: https://www.amazon.ca/Effective-Modern-Specific-Ways-Improve/dp/1491903996


Thanks, I know what you mean. I'm also reading that book. However, my colleagues are usually against auto outside ranged for loops. To be honest, I can't say it helps there too much either.


for (const auto& elem : vec)
{

}



for (const SomeObj& elem : vec)
{

}


I'd say the latter is far from unreadable and you don't use iterator's long syntax.
Mr. Wiggles
Profile Blog Joined August 2010
Canada5894 Posts
April 29 2016 23:37 GMT
#14479
On April 30 2016 08:05 Shield wrote:
Show nested quote +
On April 30 2016 07:58 Mr. Wiggles wrote:
On April 30 2016 07:23 Shield wrote:
Has anyone tried C++11/14 yet? What do you like and what don't you like?

I haven't used it too heavily yet outside of some of the quality of life improvements.

I enjoy using the new type inference stuff. For example, auto is very nice and helps with not having to always type out full type names, especially when the type doesn't exactly help with readability.

Range-based iteration is also nice. Compare:

for (std::vector<SomeObj>::iterator it = vec.begin(); it != vec.end(); ++it) {
// Do stuff
}


for (auto &elem : vec) {
// Do stuff
}


I like using lambda functions (closures) as well. When used effectively, they can simplify some code and make it easier to read.

The changes to initialization are a welcome addition also. There's also been some changes introduced that allow you to lean on the compiler a little more, which is nice. For example: constexpr, strongly typed enumerations, etc.

Like I said, I haven't used too many of the more advanced features, but just these ones and a few others result in much cleaner and readable code than before when they're leveraged effectively. Overall, I like the introduced changes.

I'd recommend this book if you'd like to learn more: https://www.amazon.ca/Effective-Modern-Specific-Ways-Improve/dp/1491903996


Thanks, I know what you mean. I'm also reading that book. However, my colleagues are usually against auto outside ranged for loops. To be honest, I can't say it helps there too much either.


for (const auto& elem : vec)
{

}



for (const SomeObj& elem : vec)
{

}


I'd say the latter is far from unreadable and you don't use iterator's long syntax.

I'd say it depends somewhat on the code you're working with. It also helps when you're working with stuff that makes heavy use of templating, where the type names by themselves might be gargantuan, and then it definitely improves readability if having the type explicitly typed out isn't required.

Another advantage of using auto is that it makes the code somewhat more maintainable as well, since type changes don't require additional code changes except where it's declared. For example, if I changed some type in a class to something with the same interface, I now don't need to go through the code and fix up anywhere it's being used. This can also be gotten around with sufficient tooling, on the other hand.

All in all, the best thing to do is to stay consistent with what your colleagues are doing, I'd say. If the benefits in your case are only marginal, it makes more sense to keep the code style consistent than to make changes that don't have full agreement across the team.
you gotta dance
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-04-30 00:13:34
April 30 2016 00:05 GMT
#14480
--- Nuked ---
Prev 1 722 723 724 725 726 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Korean Royale
12:00
Group Stage 1 - Group A
WardiTV559
LiquipediaDiscussion
Kung Fu Cup
12:00
2025 Monthly #3: Day 5
Cure vs herOLIVE!
Reynor vs TBD
RotterdaM693
TKL 366
IndyStarCraft 269
SteadfastSC122
IntoTheiNu 43
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 617
TKL 352
Tasteless 324
Reynor 276
IndyStarCraft 269
Rex 147
SteadfastSC 113
Railgan 25
MindelVK 21
StarCraft: Brood War
Britney 36790
Rain 8932
Sea 4139
firebathero 4096
BeSt 1748
Horang2 1687
GuemChi 939
Soma 605
EffOrt 552
Stork 500
[ Show more ]
Mini 456
actioN 283
Rush 225
Killer 174
Last 146
Hyun 144
scan(afreeca) 136
hero 133
Bonyth 99
Mind 90
Barracks 61
Sharp 51
zelot 50
yabsab 49
Sea.KH 45
sorry 42
Snow 39
sas.Sziky 24
Shinee 18
Hm[arnc] 15
NaDa 8
Bale 6
Dota 2
singsing3070
qojqva1678
Dendi1083
Gorgc737
XcaliburYe301
Counter-Strike
byalli539
x6flipin531
Heroes of the Storm
Khaldor238
Liquid`Hasu193
Other Games
FrodaN4939
B2W.Neo1844
Pyrionflax359
Fuzer 256
KnowMe216
DeMusliM40
Organizations
Dota 2
PGL Dota 2 - Main Stream14873
PGL Dota 2 - Secondary Stream1808
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Adnapsc2 8
• Dystopia_ 6
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV606
• Ler66
Upcoming Events
BSL 21
6h 7m
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
6h 7m
Dewalt vs WolFix
eOnzErG vs Bonyth
Replay Cast
9h 7m
Wardi Open
22h 7m
Monday Night Weeklies
1d 3h
Replay Cast
1d 9h
WardiTV Korean Royale
1d 22h
BSL: GosuLeague
2 days
The PondCast
2 days
Replay Cast
3 days
[ Show More ]
RSL Revival
3 days
BSL: GosuLeague
4 days
RSL Revival
4 days
WardiTV Korean Royale
4 days
RSL Revival
5 days
WardiTV Korean Royale
5 days
IPSL
6 days
Julia vs Artosis
JDConan vs DragOn
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-11-14
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
CSCL: Masked Kings S3
SLON Tour Season 2
RSL Revival: Season 3
META Madness #9
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Disclosure: This page contains affiliate marketing links that support TLnet.

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.