{"id":4312,"date":"2014-03-30T09:48:24","date_gmt":"2014-03-30T09:48:24","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-member-function-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:48:24","modified_gmt":"2014-03-30T09:48:24","slug":"problem-about-member-function-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-member-function-collection-of-common-programming-errors\/","title":{"rendered":"problem about member-function-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/23b4e51e418aafdc0078b12862e2f4c4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\niavr<br \/>\nc++ templates c++11 member-function ref-qualifier<br \/>\nThis compiles fine in clang 3.3:template &lt;typename T&gt; struct M;template &lt;typename R, typename C, typename&#8230; A&gt; struct M &lt;R (C::*)(A&#8230;)&gt; { };template &lt;typename R, typename C, typename&#8230; A&gt; struct M &lt;R (C::*)(A&#8230;) &amp;&gt; { };but fails in gcc 4.8.1:[&#8230;] error: redefinition of &#8216;struct M &lt;R (C::*)(A &#8230;)&gt;&#8217;struct M &lt;R (C::*)(A&#8230;) &amp;&gt; { };^ [&#8230;] error: previous definition of &#8216;struct M &lt;R (C::*)(A &#8230;)&gt;&#8217;struct M &lt;R (C::*)(A&#8230;)&gt; { };^When u<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/cd05c493e7c2e241e814b66a9bf3d826?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\npmr<br \/>\nc++ design boolean default-arguments member-function<br \/>\nWe have several classes where a call to a member function may change state and sometimes not depending on a boolean with default value.A a;a.set( &#8220;foobar&#8221; );assert( a.changed() == true );versusA a;a.set( &#8220;foobar&#8221;, false );assert( a.changed() == false );Please note that those member functions are virtual. I would favor to use an alias to better read code and make a private member function still allowing the old method and give only the wrappers to the public:a.silentlySet( &#8220;foobar&#8221; ) {a.set( &#8220;foo<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9984aeb6979f395c2723adf67d77d2cf?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlinks77<br \/>\nc++ boost bind signals member-function<br \/>\nIs it safe to use std::bind to pass a member function to boost::signals2::signal::connect()? In other words, is boost::bind and std::bind interchangeable?It compiles with VC++ 2010 SP1, but the template code is way over my head and I&#8217;m afraid I might be venturing into undefined behaviour territory.<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>iavr c++ templates c++11 member-function ref-qualifier This compiles fine in clang 3.3:template &lt;typename T&gt; struct M;template &lt;typename R, typename C, typename&#8230; A&gt; struct M &lt;R (C::*)(A&#8230;)&gt; { };template &lt;typename R, typename C, typename&#8230; A&gt; struct M &lt;R (C::*)(A&#8230;) &amp;&gt; { };but fails in gcc 4.8.1:[&#8230;] error: redefinition of &#8216;struct M &lt;R (C::*)(A &#8230;)&gt;&#8217;struct M &lt;R [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4312","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4312"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4312\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}