<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7829769773076278106</id><updated>2012-02-16T16:59:38.286-08:00</updated><title type='text'>developer for work</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://developer4work.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7829769773076278106/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://developer4work.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>thrantir</name><uri>http://www.blogger.com/profile/07720685051427136187</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7829769773076278106.post-570222806877289953</id><published>2008-11-28T02:38:00.000-08:00</published><updated>2009-03-11T06:43:46.965-07:00</updated><title type='text'>Move constructor</title><content type='html'>Gaetano, the owner of cpp-today blog (see the link on the right) read my previous post and explain me that a constructor like T(T&amp;) is the base of the "Move Constructor Idiom"&lt;br /&gt;&lt;br /&gt;The programmer that wrote the (horrible) code of the previous post hasn't thinking about that, he just don't know the correct prototype of a copy constructor, but I didn't know anything about that move constructor so I read something about&lt;br /&gt;&lt;br /&gt;This idiom comes out when there-s the need of "move semantic". In practice we want to "copy" an object modifying the one passed as parameter. The main example of a class that need a move constructor is std::auto_ptr.&lt;br /&gt;You can read more &lt;a href="http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Move_Constructor"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Then, it a good practice to pay attention on constructor declarations, to avoid undesirable behaviors&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7829769773076278106-570222806877289953?l=developer4work.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://developer4work.blogspot.com/feeds/570222806877289953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7829769773076278106&amp;postID=570222806877289953' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7829769773076278106/posts/default/570222806877289953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7829769773076278106/posts/default/570222806877289953'/><link rel='alternate' type='text/html' href='http://developer4work.blogspot.com/2008/11/move-constructor.html' title='Move constructor'/><author><name>thrantir</name><uri>http://www.blogger.com/profile/07720685051427136187</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7829769773076278106.post-8685579837186939848</id><published>2008-11-27T08:55:00.000-08:00</published><updated>2008-11-27T09:35:37.406-08:00</updated><title type='text'>Why following the standard  is the right thing..</title><content type='html'>Today I saw an interesting example of bad C++ coding:&lt;br /&gt;&lt;br /&gt;Let's say we have a class, named A, that have a strange copy constructor prototype:&lt;br /&gt;&lt;br /&gt;class A {&lt;br /&gt;    public:&lt;br /&gt;        &lt;span style="font-weight:bold;"&gt;A(A&amp; an_a)&lt;/span&gt; {...}&lt;br /&gt;    [...]&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;the standard says that the copy constructor for a type T has to have this prototype:&lt;br /&gt;&lt;br /&gt;T(&lt;span style="font-weight:bold;"&gt;const&lt;/span&gt; T&amp;);&lt;br /&gt;&lt;br /&gt;so, the instance passed as argument has to be const!&lt;br /&gt;&lt;br /&gt;My compiler (g++ 4.2.4), doesn't complain even if I specify -Wall and -pedantic, and the code is generated...&lt;br /&gt;&lt;br /&gt;Let's go ahead, let's say we have a class MyClass that has an attribute of type A, and this method:&lt;br /&gt;&lt;br /&gt;A MyClass::getA() const {return this-&gt;the_a;}&lt;br /&gt;&lt;br /&gt;We don't return a reference to the attribute, we want to return a copy, no matter why...&lt;br /&gt;&lt;br /&gt;We aren't using this method yet, but we are careful programmers so we try to compile our code... surprise! The compile complains because it's missing a A::A(A) constructor... damn, why it isn't using the copy constructor we wrote??? Oh yes!, the getA() method is const! Let's erase that swaerword!!! Oh, that's fine, the compilers doesn't complain anymore!&lt;br /&gt;&lt;br /&gt;Now, we want to use our nice method so somewhere we have something like this:&lt;br /&gt;&lt;br /&gt;A my_a = my_class.getA();&lt;br /&gt;&lt;br /&gt;What? The compiler complains again? The same error? What does he wants? Nothing here is const!!!&lt;br /&gt;&lt;br /&gt;And that's the truth: we didn't follow the standard and the standard punished ourselves! The compiler need to do a copy of a temporary variable and temporary variables in C++ are all const! If you try to add a constructor like this:&lt;br /&gt;&lt;br /&gt;A::A(A)&lt;br /&gt;&lt;br /&gt;the compilers will complain for a wrong constructor too! That's the end, we have to bow our heads and follow the standard&lt;br /&gt;&lt;br /&gt;The moral of the story is: you have to follow the standard, otherwise the standard will have its revenge!&lt;br /&gt;&lt;br /&gt;PS Is it possible to read code like that written by a senior C++ developer?????&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7829769773076278106-8685579837186939848?l=developer4work.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://developer4work.blogspot.com/feeds/8685579837186939848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7829769773076278106&amp;postID=8685579837186939848' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7829769773076278106/posts/default/8685579837186939848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7829769773076278106/posts/default/8685579837186939848'/><link rel='alternate' type='text/html' href='http://developer4work.blogspot.com/2008/11/why-following-standard-is-right-thing.html' title='Why following the standard  is the right thing..'/><author><name>thrantir</name><uri>http://www.blogger.com/profile/07720685051427136187</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7829769773076278106.post-8532391216937888008</id><published>2008-10-16T04:43:00.000-07:00</published><updated>2008-10-16T04:51:54.460-07:00</updated><title type='text'>look the path!</title><content type='html'>Today I fix a stupid, trivial issue on building a win32 executable from python code... the problem was a missing library, but the library was in the correct place!!! Al last, I fund there are two python interpreter on my machine, the one I installed and another... installed by cygwin!!! Clearly, when I write "python.exe" on my prompt the first interpreter the system find is the cygwin one, that hasn't the libraries I need... just add the correct path and the issue disappeared!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7829769773076278106-8532391216937888008?l=developer4work.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://developer4work.blogspot.com/feeds/8532391216937888008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7829769773076278106&amp;postID=8532391216937888008' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7829769773076278106/posts/default/8532391216937888008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7829769773076278106/posts/default/8532391216937888008'/><link rel='alternate' type='text/html' href='http://developer4work.blogspot.com/2008/10/look-path.html' title='look the path!'/><author><name>thrantir</name><uri>http://www.blogger.com/profile/07720685051427136187</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7829769773076278106.post-1154156816684596458</id><published>2008-10-13T09:08:00.000-07:00</published><updated>2008-10-13T09:11:00.359-07:00</updated><title type='text'>developer life</title><content type='html'>Hi to all!&lt;br /&gt;&lt;br /&gt;I'm a developer, a C++ developer... not a very good one, but I like to improve my developing abilities...&lt;br /&gt;&lt;br /&gt;so, I'll use this space to fix what I'll discover :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7829769773076278106-1154156816684596458?l=developer4work.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://developer4work.blogspot.com/feeds/1154156816684596458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7829769773076278106&amp;postID=1154156816684596458' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7829769773076278106/posts/default/1154156816684596458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7829769773076278106/posts/default/1154156816684596458'/><link rel='alternate' type='text/html' href='http://developer4work.blogspot.com/2008/10/developer-life.html' title='developer life'/><author><name>thrantir</name><uri>http://www.blogger.com/profile/07720685051427136187</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
