Dave Abrahams has a pretty comprehensive analysis of the speed of passing/returning values.
Short answer, if you need to return a value then return a value. Don't use output references because the compiler does it anyway. Of course there are caveats, so you should read that article.
link mostly answer has dead link
anyone feel like using the wayback machine to fix?
I have a function foo that can throw a bar exception.
In another function I call foo but I have the ability to add some more detail to the bar exception if thrown. (I'd rather not pass such information as a parameter to foo as it doesn't really belong there due to the generic nature of that func...
At least IMO, it's usually a poor idea, but not for efficiency reasons. It's a poor idea because the function in question should usually be written as a generic algorithm that produces its output via an iterator. Almost any code that accepts or returns a container instead of operating on iterator...
@Mgetz If you try to invoke any kind of non-builtin method or property on an entity, LINQ bitches that it can't evaluate it, even though the implementation is trivial (e.g. returning a constant).
> Hi Dave, > > Not sure whether you may already be aware, but the two listed websites are currently offline with an Apache holding page. Currently there are a lot of links to your content (e.g. http://stackoverflow.com/a/3134855/560648) so hopefully this is not the end of it! > > Best regards, > Tom
Today my team was part of the Visual Studio 2015 Preview announcement, and it’s nice to be able to share that Visual Studio is now going to support targeting Android and soon iOS, using the Clang compiler, from right inside VS. This is in addition to continued conformance and other improvements in our own VC++ compiler […]
David Abrahams is a computer programmer and author. He is most well known for his activities related to the C++ programming language. In particular his contributions to the language include the delineating of a theory of exceptions, sitting on the C++ Standards Committee, being a founding member of Boost and co-authoring a book on the subject of template meta-programming.
Abrahams became a member of the C++ Standards Committee in 1996. During the standardization process that resulted in the first ANSI standard C++ - in 1998 - Abrahams was a principal driving force behind detailing the exception...
I’ve got the following situation:
develop
------o
\
\ master
---o-----o-----o-----o-----o-----o-----o
\ / A B
\ /
o-----o-----o
Here, I accidentally developed feature branches A and B on top of master inste...
@Mgetz Hmm. Pulling from dev won’t remove the past master commits though. I cannot revert those, since I still need them (but on master, not the other branches)
guys, I've got a tip for you if you're using chrome
you can edit search engines in chrome with a keyword
so if you add a search engine with the keyword "cpp" and as URL http://en.cppreference.com/mwiki/index.php?title=Special:Search&search=%s all you have to do is type cpp vector in your URL bar to go to en.cppreference.com/w/cpp/container/vector
@caps In the standard or almost any good book on C++. The basic idea is to model your functions to follow the same style as the existing algorithms in the standard library. For one example, consider the second code snippet here.
@caps Effective STL is largely about how to use the existing standard library code, but the familiarity with it provides a decent guide about how to write similar code yourself.
Is there a 'best practice' for how to implement methods in libraries that are intended to be loaded at runtime?
Like, I feel like all the public methods should be virtual (so changing things doesn't change binary compatibility), but I'm curious what else is out there. Does that make sense?
@JerryCoffin Hm. Getting ready to write a little search panel module. I want to separate the interface (displaying items in a custom-drawn listbox) from the implementation (pulling data from our SQL db).
And actually I'm thinking one further layer than what I described. Search module object has functions for searching for this or that and can tell you the results, but the actual searching and returning is handled by a separate unit in the Search module. Then the form is just a wrapper on the Search module object. But since it needs to draw the results in the listbox it needs to get them from the Search module object, either in a container or through iterators or a GetNextResult() or something.
@QuestionC If you frame this not in asking for "best practice", but in asking whether any industry standard exists for ensuring binary compatibility and avoiding dependency hell, you'll avoid the close-cos-opinions hammer. However, you'll almost assuredly get closed-cos-dupe.
@QuestionC Depends on the OS you want to support. For Windows, you can create a COM object (which is basically a standardized version of what you described--what's exported is basically a vtable). For the general case, you just about have to funnel everything through a C interface.
Generally, though, you find a list of code changes that break binary compatibility, and when you make any of those changes, you bump your library's minor version level. If you don't make any of those changes, just bump the patch revision and worry no more about it.
@QuestionC Why? Someone pointing you to your answer, for free! It's free research-for-hire! Do you have any idea how much a research assistant costs in the real world?
> I feel like all the public methods should be virtual (so changing things doesn't change binary compatibility)
> If a person comes to me ans says "PHP cant do this or that." . I respond : "Language is a tool to make awesome website/software, it depends upon you how much you can do with it ? Can you create your own Facebook????? If not then please recheck WHAT YOU JUST SAID ,Period !!! ".
@Columbo And -1 to you too (for also being disrespectful to idiots PHP devs). Think how lonely those drivers of short buses would get if there weren't future PHP devs to keep them company!
@JerryCoffin it'll take a lot of work. if i'm offended, it's usually vaguely. about all you could do is put a @cHao in it, and even that would require knowing i'll read it :)
@StackedCrooked Careful how you tell Americans about that ("chapter 13" is often used to refer to chapter 13 of US law, which deals with a form of bankruptcy).
@LightnessRacesinOrbit Oh thanks. It's so nice to know that my respect for those who signed up for service and died for it is now associated with... that:( Imma burning my poppy.
BTW your respect is not tainted by other people's respect and other people's respect shouldn't be tainted by your opinion on the unrelated opinions of those other people so pipe down
I completely missed the silence though :( Either my entire company forgot (which is not a stretch), or I was listening to music on my headphones and nobody around me dared interrupt me
@StackedCrooked Depends heavily on your definition of "a lot". They've always been pretty much fringe languages. In the '80s there was a Japanese "fifth generation computer project" that was (famously) based on Prolog. Nearly all other use/study of Prolog seems to have stemmed from that, and the assumption that it would eventually mean something (which turned out false).
@JerryCoffin because whenever an operation removes an element a bit of free space gets created, and you have the option to add the free space to the front or to the back
@LightnessRacesinOrbit je moet een keertje een broodje shoarma eten in Amsterdam
@JerryCoffin for example assign potentially generates a lot of free capacity, does that mean I should make two alternatives assign_front and assign_back?
@JerryCoffin that would violate the contiguous memory requirement, no? plus make indexing expensive
@orlp I can see where you could, but I'm not sure I would. For assign, I think I'd just plop the data into the middle of the buffer, and leave it at that.
@orlp Since you're the one writing the requirement(s), I'm not sure whether a wraparound violates them or not. It could make indexing expensive though.
@orlp Sure--but the point (as I recall it) was to act more like a deque.
@MartinJames No--until the constructor completes, no instance exists, so there's no instance on which to call the destructor until the ctor finishes execution and returns.
The semantics are pretty well understood at this point, it's really a question of do they go ahead and just make them a library feature or language feature
@Mgetz Like a lot of the thread/atomic operations stuff, it should probably be mostly defined in the library, but with a little bit of language support.