<?xml version="1.0" encoding="utf-8"?>
<!-- If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/ -->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:lj="http://www.livejournal.com">
  <id>urn:lj:livejournal.com:atom1:advancedcpp</id>
  <title>Advanced C++ Community</title>
  <subtitle>Advanced C++ Community</subtitle>
  <author>
    <name>Advanced C++ Community</name>
  </author>
  <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/"/>
  <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom"/>
  <updated>2007-12-23T23:21:39Z</updated>
  <lj:journal username="advancedcpp" type="community"/>
  <link rel="service.feed" type="application/x.atom+xml" href="http://community.livejournal.com/advancedcpp/data/atom" title="Advanced C++ Community"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:33080</id>
    <author>
      <name>Tom</name>
    </author>
    <lj:poster user="ataxi"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/33080.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=33080"/>
    <title>Hardware independent (sort of) compare and swap?</title>
    <published>2007-12-23T23:21:39Z</published>
    <updated>2007-12-23T23:21:39Z</updated>
    <content type="html">Is anyone aware of an existing free-as-in-beer codebase that provides an abstraction for compare-and-swap across common hardware types?&lt;br /&gt;&lt;br /&gt;I am writing a fairly simple lock-free buffer type and would like to avoid doing the assembler myself.  The platforms which I have an immediate interest in supporting are x86 and SPARC v9: nothing exotic.&lt;br /&gt;&lt;br /&gt;I've done some hunting and pleasingly it looks like these atomic ops are quite likely to go into the C++ standard at some point (in C++0F or whatever), however I can't find anything concrete in terms of an implementation yet.&lt;br /&gt;&lt;br /&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:32903</id>
    <author>
      <name>Zannie</name>
    </author>
    <lj:poster user="jedipussytricks"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/32903.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=32903"/>
    <title>New to threads</title>
    <published>2007-12-21T02:08:32Z</published>
    <updated>2007-12-21T17:54:11Z</updated>
    <content type="html">I've never written any threaded applications before, but I have one that could probably benefit from it.  I'm looking at converting it over using Boost.&lt;br /&gt;&lt;br /&gt;I have found the &lt;a href="http://www.ddj.com/cpp/184401518"&gt;Dr. Dobbs article&lt;/a&gt;, which seems to have the best and most numerous examples of Boost threading, but I'm still unclear on how to actually get the different threads to execute in parallel.  I'm really just starting out here, so maybe I'm just misinterpreting, but it looks like in the examples the threads are executed serially, which doesn't make any sense.  I must misunderstand something.&lt;br /&gt;&lt;br /&gt;I admit my impatience with reading the whole article in detail, because my particular application seems--to my naive self--to naturally avoid the major pitfalls of threading.&lt;br /&gt;&lt;br /&gt;Basically, it creates a collection of Recipients, and for each recipient: &lt;br /&gt; - queries for some information to email to the recipient&lt;br /&gt; - emails the information to the Recipient&lt;br /&gt; - deletes the database records that led to the email being sent (no two recipients will share a record, and this is MySQL, so there will be no table locks)&lt;br /&gt; - logs the sending of the email in another database table&lt;br /&gt; - updates a record of the last time the user received an email&lt;br /&gt;&lt;br /&gt;Rather than processing each recipient serially in a loop, I'd like to be able to spawn a thread for each recipient.  I'm thinking that I need to combine all of the per-recipient tasks into a single function and then spawn a new thread of that function for each recipient.  Am I on the right track?  Do I need to use a thread_group so I can dynamically create threads rather than instantiating specific named threads, as is done in all of the Dr. Dobbs examples?&lt;br /&gt;&lt;br /&gt;Here is the gist of the application.  The mailer is a functor.&lt;br /&gt;&lt;br /&gt;&lt;a name="cutid1"&gt;&lt;/a&gt;&lt;br /&gt;&lt;pre&gt;
  try {
    bool recipients_found = load_recipient_data();
    if (recipients_found) {
      Summary_Mailer mailer(get_url_domain(), get_bounce_address(), destination_template, mail_drop, verbose);

      for (summary_recipient_hash_map::iterator recipient_it = recipients.begin(); recipient_it != recipients.end(); ++recipient_it) {
        set_recipient_documents(&amp;(recipient_it-&amp;gt;second));

        if (!recipient_it-&amp;gt;second.documents.empty()) {
          mailer(&amp;(recipient_it-&amp;gt;second));
          cleanup_research_summary_email(recipient_it-&amp;gt;second);
          insert_email_sent_summary_research_activity(recipient_it-&amp;gt;second);
        }

        update_user_research_summary_options(recipient_it-&amp;gt;second);
      }
    }

    user_db.logoff();
    document_db.logoff();

  } 
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Any applicable advice appreciated.  Alliteration optional.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:32750</id>
    <author>
      <name>Lover of Ideas</name>
    </author>
    <lj:poster user="omnifarious"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/32750.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=32750"/>
    <title>Callback for something that might disappear</title>
    <published>2007-10-21T08:31:55Z</published>
    <updated>2007-10-21T18:44:24Z</updated>
    <content type="html">&lt;p&gt;I wanted to have a fairly robust callback that would call something that might disappear before the callback is triggered.  I wanted the callback to simply go dead when its target disappeared.&lt;/p&gt;
&lt;p&gt;I thought about it a lot, and I came up with this:&lt;/p&gt;
&lt;a name="cutid1"&gt;&lt;/a&gt;
&lt;hr /&gt;
&lt;pre class="hl"&gt;&lt;span style="color:#008200"&gt;#include &amp;lt;boost/function.hpp&amp;gt;&lt;/span&gt;
&lt;span style="color:#008200"&gt;#include &amp;lt;boost/intrusive_ptr.hpp&amp;gt;&lt;/span&gt;
&lt;span style="color:#008200"&gt;#include &amp;lt;boost/bind.hpp&amp;gt;&lt;/span&gt;
&lt;span style="color:#008200"&gt;#include &amp;lt;boost/lambda/core.hpp&amp;gt;&lt;/span&gt;
&lt;span style="color:#008200"&gt;#include &amp;lt;boost/lambda/lambda.hpp&amp;gt;&lt;/span&gt;
&lt;span style="color:#008200"&gt;#include &amp;lt;boost/lambda/if.hpp&amp;gt;&lt;/span&gt;
&lt;span style="color:#008200"&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;using&lt;/span&gt; &lt;span style="color:#000000"&gt;::&lt;/span&gt;std&lt;span style="color:#000000"&gt;::&lt;/span&gt;cout&lt;span style="color:#000000"&gt;;&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;class&lt;/span&gt; existence_guardmaster &lt;span style="color:#000000"&gt;{&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;class&lt;/span&gt; guard_t&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;class&lt;/span&gt; isvalid_wrapper&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;friend class&lt;/span&gt; isvalid_wrapper&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;friend&lt;/span&gt; &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;intrusive_ptr_add_ref&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;guard_t &lt;span style="color:#000000"&gt;*);&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;friend&lt;/span&gt; &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;intrusive_ptr_release&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;guard_t &lt;span style="color:#000000"&gt;*);&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;typedef&lt;/span&gt; &lt;span style="color:#000000"&gt;::&lt;/span&gt;boost&lt;span style="color:#000000"&gt;::&lt;/span&gt;intrusive_ptr&lt;span style="color:#000000"&gt;&amp;lt;&lt;/span&gt;guard_t&lt;span style="color:#000000"&gt;&amp;gt;&lt;/span&gt; guardptr_t&lt;span style="color:#000000"&gt;;&lt;/span&gt;

 &lt;span style="color:#000000; font-weight:bold"&gt;public&lt;/span&gt;&lt;span style="color:#000000"&gt;:&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;typedef&lt;/span&gt; &lt;span style="color:#000000"&gt;::&lt;/span&gt;boost&lt;span style="color:#000000"&gt;::&lt;/span&gt;function&lt;span style="color:#000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#830000"&gt;void&lt;/span&gt;&lt;span style="color:#000000"&gt;)&amp;gt;&lt;/span&gt; wrapped_t&lt;span style="color:#000000"&gt;;&lt;/span&gt;

   &lt;span style="color:#010181"&gt;existence_guardmaster&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#830000"&gt;bool&lt;/span&gt; startvalid &lt;span style="color:#000000"&gt;=&lt;/span&gt; &lt;span style="color:#000000; font-weight:bold"&gt;true&lt;/span&gt;&lt;span style="color:#000000"&gt;);&lt;/span&gt;
   &lt;span style="color:#000000"&gt;~&lt;/span&gt;&lt;span style="color:#010181"&gt;existence_guardmaster&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;

   &lt;span style="color:#830000"&gt;bool&lt;/span&gt; &lt;span style="color:#010181"&gt;isvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;
   &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;setinvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;
   &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;setvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;

   &lt;span style="color:#830000"&gt;const&lt;/span&gt; wrapped_t &lt;span style="color:#010181"&gt;wrap_with_guard&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#830000"&gt;const&lt;/span&gt; wrapped_t &lt;span style="color:#000000"&gt;&amp;amp;&lt;/span&gt;func&lt;span style="color:#000000"&gt;)&lt;/span&gt; &lt;span style="color:#830000"&gt;const&lt;/span&gt;&lt;span style="color:#000000"&gt;;&lt;/span&gt;

 &lt;span style="color:#000000; font-weight:bold"&gt;private&lt;/span&gt;&lt;span style="color:#000000"&gt;:&lt;/span&gt;
   &lt;span style="color:#830000"&gt;const&lt;/span&gt; guardptr_t guard_&lt;span style="color:#000000"&gt;;&lt;/span&gt;
&lt;span style="color:#000000"&gt;};&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;class&lt;/span&gt; existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;guard_t &lt;span style="color:#000000"&gt;{&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;friend class&lt;/span&gt; existence_guardmaster&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;friend&lt;/span&gt; &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;intrusive_ptr_add_ref&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;guard_t &lt;span style="color:#000000"&gt;*);&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;friend&lt;/span&gt; &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;intrusive_ptr_release&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;guard_t &lt;span style="color:#000000"&gt;*);&lt;/span&gt;
   &lt;span style="color:#830000"&gt;bool&lt;/span&gt; valid_&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#830000"&gt;unsigned int&lt;/span&gt; refs_&lt;span style="color:#000000"&gt;;&lt;/span&gt;

   &lt;span style="color:#010181"&gt;guard_t&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#830000"&gt;bool&lt;/span&gt; startvalid&lt;span style="color:#000000"&gt;) :&lt;/span&gt; &lt;span style="color:#010181"&gt;valid_&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;startvalid&lt;span style="color:#000000"&gt;),&lt;/span&gt; &lt;span style="color:#010181"&gt;refs_&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#2928ff"&gt;0&lt;/span&gt;&lt;span style="color:#000000"&gt;) { }&lt;/span&gt;
   &lt;span style="color:#830000"&gt;bool&lt;/span&gt; &lt;span style="color:#010181"&gt;isvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;()&lt;/span&gt; &lt;span style="color:#830000"&gt;const&lt;/span&gt; &lt;span style="color:#000000"&gt;{&lt;/span&gt;
      &lt;span style="color:#000000; font-weight:bold"&gt;return&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;valid_&lt;span style="color:#000000"&gt;);&lt;/span&gt;
   &lt;span style="color:#000000"&gt;}&lt;/span&gt;
   &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;setinvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;() {&lt;/span&gt;
      valid_ &lt;span style="color:#000000"&gt;=&lt;/span&gt; &lt;span style="color:#000000; font-weight:bold"&gt;false&lt;/span&gt;&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#000000"&gt;}&lt;/span&gt;
   &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;setvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;() {&lt;/span&gt;
      valid_ &lt;span style="color:#000000"&gt;=&lt;/span&gt; &lt;span style="color:#000000; font-weight:bold"&gt;true&lt;/span&gt;&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#000000"&gt;}&lt;/span&gt;
&lt;span style="color:#000000"&gt;};&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;inline&lt;/span&gt; existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;&lt;span style="color:#010181"&gt;existence_guardmaster&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#830000"&gt;bool&lt;/span&gt; startvalid&lt;span style="color:#000000"&gt;)&lt;/span&gt;
     &lt;span style="color:#000000"&gt;:&lt;/span&gt; &lt;span style="color:#010181"&gt;guard_&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#000000; font-weight:bold"&gt;new&lt;/span&gt; &lt;span style="color:#010181"&gt;guard_t&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;startvalid&lt;span style="color:#000000"&gt;))&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;inline&lt;/span&gt; existence_guardmaster&lt;span style="color:#000000"&gt;::~&lt;/span&gt;&lt;span style="color:#010181"&gt;existence_guardmaster&lt;/span&gt;&lt;span style="color:#000000"&gt;()&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
   guard_&lt;span style="color:#000000"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#010181"&gt;setinvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;inline&lt;/span&gt; &lt;span style="color:#830000"&gt;bool&lt;/span&gt; existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;&lt;span style="color:#010181"&gt;isvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;()&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;return&lt;/span&gt; guard_&lt;span style="color:#000000"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#010181"&gt;isvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;inline&lt;/span&gt; &lt;span style="color:#830000"&gt;void&lt;/span&gt; existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;&lt;span style="color:#010181"&gt;setinvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;()&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
   guard_&lt;span style="color:#000000"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#010181"&gt;setinvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;inline&lt;/span&gt; &lt;span style="color:#830000"&gt;void&lt;/span&gt; existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;&lt;span style="color:#010181"&gt;setvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;()&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
   guard_&lt;span style="color:#000000"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#010181"&gt;setvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;class&lt;/span&gt; existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;isvalid_wrapper &lt;span style="color:#000000"&gt;{&lt;/span&gt;
 &lt;span style="color:#000000; font-weight:bold"&gt;public&lt;/span&gt;&lt;span style="color:#000000"&gt;:&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;typedef&lt;/span&gt; &lt;span style="color:#830000"&gt;void&lt;/span&gt; result_type&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#010181"&gt;isvalid_wrapper&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#830000"&gt;const&lt;/span&gt; guardptr_t &lt;span style="color:#000000"&gt;&amp;amp;&lt;/span&gt;ptr&lt;span style="color:#000000"&gt;,&lt;/span&gt; &lt;span style="color:#830000"&gt;const&lt;/span&gt; wrapped_t &lt;span style="color:#000000"&gt;&amp;amp;&lt;/span&gt;func&lt;span style="color:#000000"&gt;)&lt;/span&gt;
        &lt;span style="color:#000000"&gt;:&lt;/span&gt; &lt;span style="color:#010181"&gt;ptr_&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;ptr&lt;span style="color:#000000"&gt;),&lt;/span&gt; &lt;span style="color:#010181"&gt;func_&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;func&lt;span style="color:#000000"&gt;)&lt;/span&gt;
   &lt;span style="color:#000000"&gt;{&lt;/span&gt;
   &lt;span style="color:#000000"&gt;}&lt;/span&gt;
   &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#000000; font-weight:bold"&gt;operator&lt;/span&gt; &lt;span style="color:#000000"&gt;()()&lt;/span&gt; &lt;span style="color:#830000"&gt;const&lt;/span&gt; &lt;span style="color:#000000"&gt;{&lt;/span&gt; &lt;span style="color:#000000; font-weight:bold"&gt;if&lt;/span&gt; &lt;span style="color:#000000"&gt;(&lt;/span&gt;ptr_&lt;span style="color:#000000"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#010181"&gt;isvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;())&lt;/span&gt; &lt;span style="color:#010181"&gt;func_&lt;/span&gt;&lt;span style="color:#000000"&gt;(); }&lt;/span&gt;
 &lt;span style="color:#000000; font-weight:bold"&gt;private&lt;/span&gt;&lt;span style="color:#000000"&gt;:&lt;/span&gt;
   &lt;span style="color:#830000"&gt;const&lt;/span&gt; guardptr_t ptr_&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#830000"&gt;const&lt;/span&gt; wrapped_t func_&lt;span style="color:#000000"&gt;;&lt;/span&gt;
&lt;span style="color:#000000"&gt;};&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;inline&lt;/span&gt; &lt;span style="color:#830000"&gt;const&lt;/span&gt; existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;wrapped_t
existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;&lt;span style="color:#010181"&gt;wrap_with_guard&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#830000"&gt;const&lt;/span&gt; wrapped_t &lt;span style="color:#000000"&gt;&amp;amp;&lt;/span&gt;func&lt;span style="color:#000000"&gt;)&lt;/span&gt; &lt;span style="color:#830000"&gt;const&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;return&lt;/span&gt; &lt;span style="color:#010181"&gt;isvalid_wrapper&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;guard_&lt;span style="color:#000000"&gt;,&lt;/span&gt; func&lt;span style="color:#000000"&gt;);&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;

&lt;span style="color:#000000; font-weight:bold"&gt;inline&lt;/span&gt; &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;intrusive_ptr_add_ref&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;guard_t &lt;span style="color:#000000"&gt;*&lt;/span&gt;guardp&lt;span style="color:#000000"&gt;)&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
   &lt;span style="color:#000000"&gt;++(&lt;/span&gt;guardp&lt;span style="color:#000000"&gt;-&amp;gt;&lt;/span&gt;refs_&lt;span style="color:#000000"&gt;);&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;

&lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;intrusive_ptr_release&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;guard_t &lt;span style="color:#000000"&gt;*&lt;/span&gt;guard&lt;span style="color:#000000"&gt;)&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
   &lt;span style="color:#000000; font-weight:bold"&gt;if&lt;/span&gt; &lt;span style="color:#000000"&gt;((&lt;/span&gt;guard&lt;span style="color:#000000"&gt;-&amp;gt;&lt;/span&gt;refs_ &lt;span style="color:#000000"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color:#2928ff"&gt;0&lt;/span&gt;&lt;span style="color:#000000"&gt;) || (--(&lt;/span&gt;guard&lt;span style="color:#000000"&gt;-&amp;gt;&lt;/span&gt;refs_&lt;span style="color:#000000"&gt;) &amp;lt;=&lt;/span&gt; &lt;span style="color:#2928ff"&gt;0&lt;/span&gt;&lt;span style="color:#000000"&gt;)) {&lt;/span&gt;
      &lt;span style="color:#000000; font-weight:bold"&gt;delete&lt;/span&gt; guard&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   &lt;span style="color:#000000"&gt;}&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;

&lt;span style="color:#830000"&gt;static&lt;/span&gt; &lt;span style="color:#000000; font-weight:bold"&gt;inline&lt;/span&gt; &lt;span style="color:#830000"&gt;void&lt;/span&gt; &lt;span style="color:#010181"&gt;thefunction&lt;/span&gt;&lt;span style="color:#000000"&gt;()&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
   &lt;span style="color:#000000"&gt;::&lt;/span&gt;std&lt;span style="color:#000000"&gt;::&lt;/span&gt;cout &lt;span style="color:#000000"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;quot;Called!&lt;/span&gt;&lt;span style="color:#ff00ff"&gt;\n&lt;/span&gt;&lt;span style="color:#ff0000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#000000"&gt;;&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;

&lt;span style="color:#830000"&gt;int&lt;/span&gt; &lt;span style="color:#010181"&gt;main&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;&lt;span style="color:#830000"&gt;int&lt;/span&gt; argc&lt;span style="color:#000000"&gt;,&lt;/span&gt; &lt;span style="color:#830000"&gt;char&lt;/span&gt; &lt;span style="color:#000000"&gt;*&lt;/span&gt;argv&lt;span style="color:#000000"&gt;[])&lt;/span&gt;
&lt;span style="color:#000000"&gt;{&lt;/span&gt;
   existence_guardmaster master&lt;span style="color:#000000"&gt;;&lt;/span&gt;
   existence_guardmaster&lt;span style="color:#000000"&gt;::&lt;/span&gt;wrapped_t wf &lt;span style="color:#000000"&gt;=&lt;/span&gt; master&lt;span style="color:#000000"&gt;.&lt;/span&gt;&lt;span style="color:#010181"&gt;wrap_with_guard&lt;/span&gt;&lt;span style="color:#000000"&gt;(&lt;/span&gt;thefunction&lt;span style="color:#000000"&gt;);&lt;/span&gt;
   &lt;span style="color:#010181"&gt;wf&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;
   master&lt;span style="color:#000000"&gt;.&lt;/span&gt;&lt;span style="color:#010181"&gt;setinvalid&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;
   &lt;span style="color:#010181"&gt;wf&lt;/span&gt;&lt;span style="color:#000000"&gt;();&lt;/span&gt;
&lt;span style="color:#000000"&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;hr /&gt;

&lt;p&gt;This results in a lot of overhead per call though.  More than I was expecting.  And the other problem is that callback functions are limited to functions with a certain signature.  You could use &lt;code&gt;boost::bind&lt;/code&gt; to bind all the arguments to your callback and store them away safely so it looked like it was &lt;code&gt;void&amp;nbsp;(void)&lt;/code&gt;, but that seems inelegant and like it wouldn't work well for some situations.&lt;/p&gt;
&lt;p&gt;It's pretty easy to do f(g(x)) in boost, but not so easy to do f(g)(x) when f is something that creates a function that largely just needs to pass things along to g.&lt;/p&gt;
&lt;p&gt;Is there a way around this?&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:31998</id>
    <author>
      <name>Adin</name>
    </author>
    <lj:poster user="tyrdinjer"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/31998.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=31998"/>
    <title>Tiered Debugging</title>
    <published>2007-08-27T10:10:11Z</published>
    <updated>2007-08-27T10:10:11Z</updated>
    <content type="html">First off, I would like to thank everyone for the discussion back in the &lt;a href="http://community.livejournal.com/advancedcpp/31589.html"&gt;Debugging post&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here is the abbreviated overview of what I created:&lt;br /&gt;&lt;br /&gt;Fine grained modularity&lt;br /&gt;Multiple levels of debugging may coexist.  The developer may have everything&lt;br /&gt;controlled from the global scope, all the way down to each debug macro having&lt;br /&gt;its own separate state.  (Though, doing the latter would probably create a&lt;br /&gt;maintenance nightmare.)&lt;br /&gt;&lt;br /&gt;Message stream inserters&lt;br /&gt;Anywhere the macro variable "message" appears, stream inserts (operator &amp;lt;&amp;lt;())&lt;br /&gt;may be used.  Thus, for example:&lt;br /&gt;&lt;br /&gt;int n = 5;&lt;br /&gt;TD_LOG("current value of n: " &amp;lt;&amp;lt; n);&lt;br /&gt;&lt;br /&gt;Static compilation&lt;br /&gt;Since every aspect of the structs used to control the behavior of Tiered Debug&lt;br /&gt;are statically defined, the compiler can eliminate any superfluous code.&lt;br /&gt;&lt;br /&gt;You can download the code and unit test from &lt;a href="http://www.adinhunterbaber.com/downloads/TieredDebug.zip"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;If anyone thinks I should clarify the documentation or add in specific examples, go ahead and tell me.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:31589</id>
    <author>
      <name>Adin</name>
    </author>
    <lj:poster user="tyrdinjer"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/31589.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=31589"/>
    <title>Debugging</title>
    <published>2007-08-13T12:11:00Z</published>
    <updated>2007-08-13T12:11:00Z</updated>
    <content type="html">I've been thinking about ways to allow differing amounts of information to be displayed while debugging a program.  And thus I came up with this possible solution.  I would like to hear what other people have to think, and would greatly welcome any constructive criticism.&lt;br /&gt;&lt;br /&gt;&lt;a name="cutid1"&gt;&lt;/a&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;
#ifdef DEBUG_FULL
#   define ASSERT_VERIFY(test, message)     do { assert((test) &amp;&amp; (message)); } while(0)
#   define LOG_DEBUG(message)               do { Log(message); } while (0)
#   define LOG_VERIFY(test, message)        do { assert((test) &amp;&amp; (message)); } while (0)
#   define THROW(ex, message)               do { assert(!(message)); } while (0)
#elseifdef DEBUG_EXTENDED
#   define ASSERT_VERIFY(test, message)     do { assert((test) &amp;&amp; (message)); } while(0)
#   define LOG_DEBUG(message)               do { Log(message); } while (0)
#   define LOG_VERIFY(test, message)        do { if (!(test)) Log(message); } while (0)
#   define THROW(ex, message)               do { throw ex(message); } while (0)
#elseifdef DEBUG_REGULAR
#   define ASSERT_VERIFY(test, message)     do { assert((test) &amp;&amp; (message)); } while(0)
#   define LOG_DEBUG(message)               do {} while (0)
#   define LOG_VERIFY(test, message)        do { if (!(test)) Log(message); } while (0)
#   define THROW(ex, message)               do { throw ex(message); } while (0)
#elseifdef DEBUG_RELEASE
#   define ASSERT_VERIFY(test, message)     do { if (!(test)) Log(message); } while(0)
#   define LOG_DEBUG(message)               do { Log(message); } while (0)
#   define LOG_VERIFY(test, message)        do { if (!(test)) Log(message); } while (0)
#   define THROW(ex, message)               do { throw ex(message); } while (0)
#else // release version
#   define ASSERT_VERIFY(test, message)     do {} while(0)
#   define LOG_DEBUG(message)               do {} while (0)
#   define LOG_VERIFY(test, message)        do { if (!(test)) Log(message); } while (0)
#   define THROW(ex, message)               do { throw ex(message); } while (0)
#endif
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;DEBUG_REGULAR&lt;/tt&gt; would be used day to day during development.  It has the following properties:&lt;br /&gt;&lt;tt&gt;ASSERT_VERIFY&lt;/tt&gt; will halt the program if the test fails.&lt;br /&gt;&lt;tt&gt;LOG_DEBUG&lt;/tt&gt; does nothing.&lt;br /&gt;&lt;tt&gt;LOG_VERIFY&lt;/tt&gt; logs any information if the test fails.  This functionality would be used in the cases where a recoverable error occurs.&lt;br /&gt;&lt;tt&gt;THROW&lt;/tt&gt; throws the specified exception.&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;DEBUG_EXTENDED&lt;/tt&gt; acts like &lt;tt&gt;DEBUG_REGULAR&lt;/tt&gt;, except &lt;tt&gt;LOG_DEBUG&lt;/tt&gt; now sends information to the log.  This way, &lt;tt&gt;LOG_DEBUG&lt;/tt&gt; can be used to send out state information that would normally clutter up the log.&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;DEBUG_FULL&lt;/tt&gt; would be used when you want the application to halt when any error is detected.&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;DEBUG_RELEASE&lt;/tt&gt; would be used when you want to track down an obscure bug, but you don't want to have the application arbitrarily halt.  The major use of this would be to send it to end users, and have them record their actions while recreating a bug.  &lt;tt&gt;ASSERT_VERIFY&lt;/tt&gt; now acts like &lt;tt&gt;LOG_VERIFY&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;RELEASE would be the standard version to give to the public.  &lt;tt&gt;ASSERT_VERIFY&lt;/tt&gt; is deactivated since you don't want the program to simply halt.  &lt;tt&gt;LOG_DEBUG&lt;/tt&gt; is also deactivated&lt;br /&gt;&lt;br /&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:30918</id>
    <author>
      <name>jetsnail</name>
    </author>
    <lj:poster user="jetsnail"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/30918.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=30918"/>
    <title>Just a funny peace of code. How you compiler processes it?</title>
    <published>2007-04-06T17:37:34Z</published>
    <updated>2007-04-06T17:37:34Z</updated>
    <content type="html">&lt;font color="#000080"&gt;struct A {&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;template&amp;lt;typename TList&amp;gt;&lt;br /&gt;struct MultipleInheritance :&lt;br /&gt;&amp;nbsp; public TList::Head,&lt;br /&gt;&amp;nbsp; public MultipleInheritance&amp;lt;typename TList::Tail&amp;gt;&lt;br /&gt;{&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;template &amp;lt;typename T1&amp;gt;&lt;br /&gt;struct RecTList {&lt;br /&gt;&amp;nbsp; typedef T1 Head;&lt;br /&gt;&amp;nbsp; typedef RecTList&amp;lt; RecTList&amp;lt;T1&amp;gt; &amp;gt; Tail;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;typedef RecTList&amp;lt;A&amp;gt; ARecTList;&lt;br /&gt;&lt;br /&gt;class RectClass : public MultipleInheritance&amp;lt;ARecTList&amp;gt; {};&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt;&amp;nbsp; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/font&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:30712</id>
    <author>
      <name>Adin</name>
    </author>
    <lj:poster user="tyrdinjer"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/30712.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=30712"/>
    <title>Psuedo Stack Trace Via Exceptions</title>
    <published>2006-12-06T03:22:03Z</published>
    <updated>2006-12-06T03:22:03Z</updated>
    <content type="html">In my post on (bad) &lt;a href="http://community.livejournal.com/advancedcpp/30128.html"&gt;optimizations&lt;/a&gt;, &lt;span class='ljuser' lj:user='iamo' style='white-space: nowrap;'&gt;&lt;a href='http://iamo.livejournal.com/profile'&gt;&lt;img src='http://p-stat.livejournal.com/img/userinfo.gif' alt='[info]' width='17' height='17' style='vertical-align: bottom; border: 0; padding-right: 1px;' /&gt;&lt;/a&gt;&lt;a href='http://iamo.livejournal.com/'&gt;&lt;b&gt;iamo&lt;/b&gt;&lt;/a&gt;&lt;/span&gt; gifted us with the neat trick of catching exceptions that are thrown in constructor lists (&lt;a href="http://community.livejournal.com/advancedcpp/30128.html?thread=234416#t234416"&gt;link&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;This got me thinking about supporting some type of stack trace in exceptions.  Here are my musings:&lt;br /&gt;&lt;a name="cutid1"&gt;&lt;/a&gt;&lt;br /&gt;1) The stack trace would be manual.  I.E., I would need to decided where I wanted a trace to occur, explicitly add the stack info, and propagate it.&lt;br /&gt;For example: &lt;code&gt;&lt;pre&gt;
try {
    // bunch of stuff
    }
catch (foo &amp;ex)
    {
    // handle foo
    }
catch (...)
    {
    // add stack info and propagate
    }
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;2) I would need to implement my own exceptions classes.  (Not a problem, as I have already done that for other various reasons.)&lt;br /&gt;&lt;br /&gt;3) The simplest way would be to use a linked list for the stack trace info.  Thus, when an exception is to be propagated, I could easily add the info into the list, and throw a new exception / rethrow the current exception. &lt;br /&gt;&lt;br /&gt;Has anyone else done this?  Do anyone have pointers / hints?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:30128</id>
    <author>
      <name>Adin</name>
    </author>
    <lj:poster user="tyrdinjer"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/30128.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=30128"/>
    <title>Optimizations</title>
    <published>2006-11-11T14:42:07Z</published>
    <updated>2006-11-11T14:42:07Z</updated>
    <content type="html">I came across this page of C++ optimizations recently (&lt;a href="http://www.custard.org/~andrew/optimize.php"&gt;http://www.custard.org/~andrew/optimize.php&lt;/a&gt;).  Some of them I consider to be fair, while others I consider to either have hidden pitfalls, or possibly even flat out wrong.  Below is a list of my reactions.  I would like to hear other people's opinions.  Especially if I missed a pitfall or misinterpreted what the optimization was for.&lt;br /&gt;&lt;a name="cutid1"&gt;&lt;/a&gt;&lt;br /&gt;&lt;b&gt;Use Initialization Lists&lt;/b&gt; - I agree with this one.  The author doesn't mention that to initialize a const object, you pretty much have to use initialization lists.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Optimize For Loops&lt;/b&gt; - this optimization will create an infinite loop if the variable is unsigned.  Also, preferring ++i over i++ is most important if they are being applied to a class.  When applied to a built in, they have the same efficiency if the return value is not used.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Use Int&lt;/b&gt; - I prefer to use types that specify their bit size.  I've seen bugs pop up where due to the fact that int was not the expected bit size.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Make Local Functions Static&lt;/b&gt; - actually, they should be put into an anonymous namespace.  The only time I use a static variable is for something like singletons.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Optimize If Statements&lt;/b&gt; - I consider this advice to be a true WTF.  Can anyone give me both a general case and and a specific case example where following the authors advice would give a speed improvement?&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Optimize Switch Statements&lt;/b&gt; - won't hurt.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Avoid Expensive Operations&lt;/b&gt; - this one is obvious to more experience programmers.  However, it also makes me think about the adage of premature optimizations.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Initialize on Declaration&lt;/b&gt; - always a good idea,&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Pass By Reference&lt;/b&gt; - fails to point out that the variable passed in may be changed by the function.  And that this can be prevented by making the variable const.  Or that built in types do not need to be passed in by reference unless they are being changed.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Delay Variable Declarations&lt;/b&gt; - I agree with this one completely.&lt;br /&gt;&lt;br /&gt;&lt;b&gt; 'op='&lt;/b&gt; - This one is true also.  Though some (most?) compilers will optimize this for you.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Inline Small Functions&lt;/b&gt; - Possible code bloat should be a concern.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Use Nameless Classes&lt;/b&gt; - If I am constantly using nameless classes in my code, it would make me wonder if I should start refactoring the code.  Otherwise, I do agree that a nameless class is better than a temp variable.&lt;br /&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:29512</id>
    <author>
      <name>Legolas</name>
    </author>
    <lj:poster user="legolas"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/29512.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=29512"/>
    <title>Lint tools on Windows?</title>
    <published>2006-11-02T21:04:13Z</published>
    <updated>2006-11-02T21:04:13Z</updated>
    <content type="html">I saw the comments to a recent entry here talk about lint tools. Do any of you use some form of lint regularly (and do they help you a lot)? &lt;br /&gt;&lt;br /&gt;And are there any free ones available for windows and/or osx, that handle C++? I searched for them a few times, and IIRC, I only found one free one that would run on Windows, that handled C only.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:28683</id>
    <author>
      <email>pphaneuf@gmail.com</email>
      <name>Pierre Phaneuf</name>
    </author>
    <lj:poster user="pphaneuf"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/28683.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=28683"/>
    <title>Am I nuts?</title>
    <published>2006-10-25T16:21:52Z</published>
    <updated>2006-10-25T16:21:52Z</updated>
    <content type="html">I'm rather offended, having been bitten by this bug. Why is it even &lt;em&gt;allowed&lt;/em&gt; to take a reference to a const reference, if it could be a copy?!?&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
#include &amp;lt;assert.h&amp;gt;

class Blah
{
public:
  const unsigned int &amp;myfoo;
  Blah(const unsigned int &amp;p):
    myfoo(p) {}
  const unsigned int getfoo()
  {
    return myfoo;
  }
};

int main()
{
  int foo(42);
  Blah baz(foo);

  ++foo;

  assert(foo == baz.getfoo());

  return 0;
}
&lt;/pre&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:28641</id>
    <author>
      <name>Alex Vinokur</name>
    </author>
    <lj:poster user="alex_vinokur"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/28641.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=28641"/>
    <title>Counter of C/C++ source lines and bytes</title>
    <published>2006-10-06T08:51:29Z</published>
    <updated>2006-10-06T08:51:29Z</updated>
    <content type="html">Counter of C/C++ source lines and bytes &lt;br /&gt;&lt;a href="https://sourceforge.net/projects/cncc/"&gt;https://sourceforge.net/projects/cncc/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="cutid1"&gt;&lt;/a&gt;&lt;br /&gt;NAME&lt;br /&gt;       cncc - count C/C++ source lines and bytes&lt;br /&gt;&lt;br /&gt;SYNOPSIS&lt;br /&gt;       cncc [OPTIONS]... [FILE]...&lt;br /&gt;&lt;br /&gt;DESCRIPTION&lt;br /&gt;       Count code-lines, empty-lines, comment-lines, &lt;br /&gt;       code-fields, empty-fields, comment-fields of C/C++-sources &lt;br /&gt;       which have been successfully compiled.&lt;br /&gt;&lt;br /&gt;       The program accepts the following options.&lt;br /&gt;&lt;br /&gt;       `-a'&lt;br /&gt;              Print code-line, empty-line and comment-line counts for each FILE.&lt;br /&gt;              This option is DEFAULT.&lt;br /&gt;&lt;br /&gt;       `-b'&lt;br /&gt;              Print line-type for each LINE of each FILE.&lt;br /&gt;&lt;br /&gt;       `-c'&lt;br /&gt;              Print&lt;br /&gt;              * line-type&lt;br /&gt;                and&lt;br /&gt;              * code-field, empty-field and comment-field counts&lt;br /&gt;              for each line of each FILE.&lt;br /&gt;              ### Note. This option is incompatible with option `-d'.&lt;br /&gt;&lt;br /&gt;       `-d'&lt;br /&gt;              Print field-type for each field of each line of each FILE.&lt;br /&gt;              ### Note. This option is incompatible with option `-c'.&lt;br /&gt;&lt;br /&gt;       `-h'&lt;br /&gt;              Display this help and exit.&lt;br /&gt;&lt;br /&gt;       `-v'&lt;br /&gt;              Print the version number and exit.&lt;br /&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:28406</id>
    <author>
      <name>Alex Vinokur</name>
    </author>
    <lj:poster user="alex_vinokur"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/28406.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=28406"/>
    <title>C/C++ Program Perfometer</title>
    <published>2006-10-01T07:11:32Z</published>
    <updated>2006-10-01T07:11:32Z</updated>
    <content type="html">&lt;a href="http://sourceforge.net/projects/cpp-perfometer/"&gt;The C/C++ Program Perfometer&lt;/a&gt; is an open source tool which enables the programmer to measure the comparative performance of a C/C++ program or of separated pieces of code by one of several desired metrics: e.g., time, memory, or metrics defined by the programmer. &lt;br /&gt;&lt;br /&gt;C/C++ Program Perfometer has been referenced at the C++ Standards Committee site:  &lt;br /&gt;&lt;a href="http://www.open-std.org/jtc1/sc22/wg21/docs/18015.html"&gt;http://www.open-std.org/jtc1/sc22/wg21/docs/18015.html&lt;/a&gt;  &lt;br /&gt;(information announcing C++ - TR 18015 Technical Report on C++ Performance).  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table style="border:1px solid #aa0033; font-size:small" align="center"&gt;
  &lt;tr&gt;
    &lt;td rowspan="3"&gt;&lt;br /&gt;     &lt;img src="http://groups.google.com/groups/img/groups_medium.gif" height="58" width="150" alt="Google Groups"&gt;&lt;br /&gt;    &lt;/td&gt;
    &lt;td colspan="2" align="center"&gt;&lt;b&gt;Subscribe to comp.lang.c++.perfometer&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;form action="http://groups.google.com/group/perfo/boxsubscribe"&gt;
  &lt;tr&gt; 
    &lt;td&gt;Email: &lt;input type="text" name="email"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;      &lt;table style="background-color:#ffcc33;padding:2px;border:2px outset #ffcc33;"&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;br /&gt;         &lt;input type="submit" name="sub" value="Subscribe"&gt;&lt;br /&gt;        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;&lt;br /&gt;    &lt;/td&gt;
  &lt;/tr&gt;
   &lt;/form&gt;
  &lt;tr&gt;&lt;td colspan="2" align="center"&gt;&lt;br /&gt;   &lt;a href="http://groups.google.com/group/perfo"&gt;Browse Archives&lt;/a&gt; at &lt;a href="http://groups.google.com/"&gt;groups.google.com&lt;/a&gt;&lt;br /&gt;  &lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:27701</id>
    <author>
      <name>Splicer Of Doom</name>
    </author>
    <lj:poster user="codesamurai"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/27701.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=27701"/>
    <title>Riddle Me This</title>
    <published>2006-08-15T14:52:00Z</published>
    <updated>2006-08-15T14:53:33Z</updated>
    <content type="html">Correct me if I'm wrong but aren't programmers just highly intelligent people paid to play with lego?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:27533</id>
    <author>
      <name>codecop</name>
    </author>
    <lj:poster user="codecop"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/27533.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=27533"/>
    <title>DevPartner or?</title>
    <published>2006-07-22T17:51:52Z</published>
    <updated>2006-07-22T17:51:52Z</updated>
    <content type="html">Is there a way to export the output report of the DevPartner (leaks) to any open format, like XML, etc... sorry for the offtopic. I just don't think any other community could possibly help.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:27018</id>
    <author>
      <name>jep</name>
    </author>
    <lj:poster user="ringzero"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/27018.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=27018"/>
    <title>Pipelining numerical computation</title>
    <published>2006-04-11T15:36:46Z</published>
    <updated>2006-04-11T15:54:56Z</updated>
    <content type="html">How do you efficiently vectorize &lt;code&gt;std::valarray&lt;/code&gt;?

&lt;p&gt;&lt;a name="cutid1"&gt;&lt;/a&gt;
I'm not sure how common this concept is, but it's something I've used for a couple years now for Fun and Profit. Some while back I wanted to write my own implementation of &lt;code&gt;std::valarray&lt;/code&gt; that could use SIMD instructions to improve performance. Given a compiler with SIMD intrinsics (I used gcc at the time) there is a fairly straightforward direct implementation; you simply implement the mathematical operations by looping over the data, loading it up into SIMD registers and performing your computation. Now, for simple code such as

&lt;blockquote&gt;
&lt;code&gt; a = b + c; &lt;/code&gt;
&lt;/blockquote&gt;

this is fine. But what about a more complex expression? To use a trivial example, how about just evaluating a quadratic over a large amount of data?

&lt;blockquote&gt;
&lt;code&gt; y = a * x * x + b * x + c; &lt;/code&gt;
&lt;/blockquote&gt;

In these more complex expressions the trivial implementation falls flat on its face, and your program ends up wasting a ton of time copying data between memory and registers unnecessarily. If we consider our data in tabular form...
&lt;p&gt;
&lt;center&gt;&lt;table border="1"&gt;
&lt;tr&gt;&lt;td&gt; a&lt;sub&gt;1&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; x&lt;sub&gt;1&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; x&lt;sub&gt;1&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; b&lt;sub&gt;1&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; x&lt;sub&gt;1&lt;/sub&gt; &lt;td&gt; c&lt;sub&gt;1&lt;/sub&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; a&lt;sub&gt;2&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; x&lt;sub&gt;2&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; x&lt;sub&gt;2&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; b&lt;sub&gt;2&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; x&lt;sub&gt;2&lt;/sub&gt; &lt;td&gt; c&lt;sub&gt;2&lt;/sub&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; a&lt;sub&gt;3&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; x&lt;sub&gt;3&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; x&lt;sub&gt;3&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; b&lt;sub&gt;3&lt;/sub&gt; &lt;/td&gt; &lt;td&gt; x&lt;sub&gt;3&lt;/sub&gt; &lt;td&gt; c&lt;sub&gt;3&lt;/sub&gt; &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; ... &lt;/td&gt; &lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;p&gt;
the trivial implementation is evaluating the expression by computing down pairs of columns, storing the intermediate values in memory each time. Ideally what we want to do is perform the computation in groups of rows, allowing us to maintain intermediate values in registers and cutting down memory use to a bare minimum.

&lt;p&gt;My solution to this is what I termed 'pipelining'. Instead of directly evaluating the data, we delay computation, instead taking the expression and using it to construct a functor which describes the calculation we want to perform, thus creating a pipeline. The computation then occurs only on demand (i.e., when you attempt to take its value) at which point data can be fed into the pipeline in chunks. Each of these SIMD-register sized chunks can then be fully evaluated before moving onto the next chunk.

&lt;p&gt;The basis of the code is to encapsulate raw data in an object like:

&lt;blockquote&gt;&lt;pre&gt;template &amp;lt;class T, unsigned int BlockSize&amp;gt;
struct _vec_data : public _vec_expr_comp&amp;lt;T, BlockSize&amp;gt;
{
  const unsigned int size;
  _vec_block&amp;lt;T, BlockSize&amp;gt; *const data;

  _vec_data(unsigned int s) :
    size(s), data(new _vec_block&amp;lt;T, BlockSize&amp;gt;[s])
  {}

  _vec_data(const _vec_data&amp; o) :
    size(o.s), data(o.val)
  {}

  _vec_block&amp;lt;T, BlockSize&amp;gt; val(unsigned int i)
  {
    return data[i];
  }
};&lt;/pre&gt;&lt;/blockquote&gt;

Where &lt;code&gt;_vec_block&lt;/code&gt; is a simple structure containing a single block of data (sized for your SIMD registers).

&lt;p&gt;Then, you implement your operands:

&lt;blockquote&gt;&lt;pre&gt;
template &amp;lt;class T, unsigned int BlockSize, class Op, class P1, class P2&amp;gt;
struct _vec_expr_bin : public _vec_expr_comp&amp;lt;T, BlockSize&amp;gt;
{
  const Op oper;
  const P1 param1;
  const P2 param2;

  _vec_expr_bin(P1 p1, P2 p2) :
    param1(p1), param2(param2), oper()
  {}

  _vec_block&amp;lt;T, BlockSize&amp;gt; val(unsigned int i)
  {
    return oper(param1.val(i), param2.val(i));
  }
};

template &amp;lt;class T, unsigned int BlockSize, class Op, class P&amp;gt;
struct _vec_expr_un : public _vec_expr_comp&amp;lt;T, BlockSize&amp;gt;
{
  const Op oper;
  const P param;

  _vec_expr_bin(P p) :
    param(p), oper()
  {}

  _vec_block&amp;lt;T, BlockSize&amp;gt; val(unsigned int i)
  {
    return oper(param.val(i));
  }
};
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;code&gt;_vec_expr_comp&lt;/code&gt; is where the magic occurs in. It's also going to be a very large class, so I won't write the whole thing out.

&lt;blockquote&gt;&lt;pre&gt;
template &amp;lt;class T, unsigned int BlockSize&amp;gt;
struct _vec_expr_comp
{
  ...

  template&amp;lt;class P1, class P2&amp;gt;
  _vec_expr_bin&amp;lt;T, BlockSize, VecAddOp, P1, P2&amp;gt; operator + (const P1&amp; p1, const P2&amp; p2)
  {
    return _vec_expr_bin&amp;lt;T, BlockSize, VecAddOp, P1, P2&amp;gt;(p1, p2);
  }

  template&amp;lt;class P&amp;gt;
  _vec_expr_un&amp;lt;T, BlockSize, VecUnaryMinus, P&amp;gt; operator - (const P&amp; p)
  {
    return _vec_expr_bin&amp;lt;T, BlockSize, VecUnaryMinus, P1, P2&amp;gt;(p);
  }

  ...
};
&lt;/pre&gt;&lt;/blockquote&gt;

Repeat those member-functions for every operator you want to implement (take similar steps for other mathematical functions you'd like to support). Finally, we move onto the actual valarray-style class.

&lt;blockquote&gt;&lt;pre&gt;
template &amp;lt;class T&amp;gt;
class valarray : public _vec_expr_comp&amp;lt;T, machine::BlockSize&amp;gt;
{
  ...

  template&amp;lt;class T&amp;gt;
  valarray&amp; operator = (const T&amp; vexpr)
  {
    // do a test to make sure T is derived from _vec_expr_comp if you want

    for (unsigned int i = 0; i &amp;lt; size() / machine::BlockSize; i++)
    {
      _vec_block&amp;lt;T, machine::BlockSize&amp;gt; block = vexpr.val(i);

      for (unsigned int j = 0; j &amp;lt; machine::BlockSize; j++)
	data[i * machine::BlockSize + j] = block.data[j];
    }
  }

  ...
};
&lt;/pre&gt;&lt;/blockquote&gt;

There are other evaluation operators that need to be implemented, such the &lt;code&gt;*=&lt;/code&gt; and similar operators, and a cast operator on &lt;code&gt;_vec_expr_comp&lt;/code&gt; so that intermediate expressions can be treated as instances of the valarray class.

&lt;p&gt;Obviously, the &lt;code&gt;machine&lt;/code&gt; structure or namespace holds the machine-specific code, and I won't elaborate on that. Also, you need to be a little more careful than I've been in these examples when you reach the end of your data, as your last calculation may not be register-sized. In this case you may need to take precautions to avoid mishaps such as accidental divide by zero errors. Also, you can't produce an exact valarray implementation with this technique, but you can create an almost-alike implementation. Slices are tricky to get right!

&lt;p&gt;The end result of this is that we, as stated above, are able to perform computations on subchunks at a time, letting us manage our memory usage more efficiently. This isn't my actual code, although on my 2ghz P4 I've found that my pipelined/vectorized valarray is between 4 and 12 times faster than the stock gcc valarray, depending on specific expression.

&lt;p&gt;Anyway, I hope you found this interesting! It was certainly a fun challenge trying to figure out how to do it.

&lt;p&gt;-jep.

&lt;p&gt;P.S. Don't forget to run with your compiler optimisations on high when you do this and spread &lt;code&gt;inline&lt;/code&gt; keywords liberally. It needs heavy function inlining to be efficient.

&lt;p&gt;( X-posting in &lt;span class='ljuser' lj:user='cpp' style='white-space: nowrap;'&gt;&lt;a href='http://community.livejournal.com/cpp/profile'&gt;&lt;img src='http://p-stat.livejournal.com/img/community.gif' alt='[info]' width='16' height='16' style='vertical-align: bottom; border: 0; padding-right: 1px;' /&gt;&lt;/a&gt;&lt;a href='http://community.livejournal.com/cpp/'&gt;&lt;b&gt;cpp&lt;/b&gt;&lt;/a&gt;&lt;/span&gt; )</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:26809</id>
    <author>
      <email>chrisb@ation.org</email>
      <name>Chris Bradfield</name>
    </author>
    <lj:poster user="cbradfield"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/26809.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=26809"/>
    <title>C++0x</title>
    <published>2006-04-11T05:58:43Z</published>
    <updated>2006-04-11T06:43:04Z</updated>
    <content type="html">What's your opinion of the new stuff coming down the pike from the standards committee? Specifically, what do you think of &lt;i&gt;Concepts&lt;/i&gt;?  For those of you who are unfamiliar with some of the new things arriving in your next C++ standard, &lt;a href="http://www.artima.com/cppsource/cpp0x.html"&gt;here is a brief summary&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Discuss.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:26388</id>
    <author>
      <email>lj@coises.com</email>
      <name>Coises (aka Randy)</name>
    </author>
    <lj:poster user="coises"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/26388.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=26388"/>
    <title>A question about derivation and virtual functions</title>
    <published>2006-04-10T19:02:20Z</published>
    <updated>2006-04-10T19:02:20Z</updated>
    <content type="html">&lt;p&gt;I was surprised by the output of this code using MSVC++ 6:&lt;/p&gt;&lt;a name="cutid1"&gt;&lt;/a&gt;&lt;pre style="FONT: 120% monospace; MARGIN-LEFT: 2em"&gt;#include &amp;lt;iostream&amp;gt;

struct t1      {virtual int id() {return 1;}};
struct t2 : t1 {        int id() {return 2;}};
struct t3 : t2 {        int id() {return 3;}};

int main() {
   t1 i1;
   t2 i2;
   t3 i3;
   t1&amp;amp; i4 = i2;
   t1&amp;amp; i5 = i3;
   t2&amp;amp; i6 = i3;
   std::cout &amp;lt;&amp;lt; i1.id() &amp;lt;&amp;lt; ' '  &amp;lt;&amp;lt; i2.id() &amp;lt;&amp;lt; ' '  &amp;lt;&amp;lt; i3.id() &amp;lt;&amp;lt; ' '
             &amp;lt;&amp;lt; i4.id() &amp;lt;&amp;lt; ' '  &amp;lt;&amp;lt; i5.id() &amp;lt;&amp;lt; ' '  &amp;lt;&amp;lt; i6.id() &amp;lt;&amp;lt; std::endl;
   return 0;
   }&lt;/pre&gt;&lt;p&gt;I expected the output to be &lt;strong&gt;1 2 3 2 2 2&lt;/strong&gt;; it was &lt;strong&gt;1 2 3&amp;nbsp;2 3 3&lt;/strong&gt;. Since &lt;strong&gt;id()&lt;/strong&gt; is not &lt;strong&gt;virtual&lt;/strong&gt; in &lt;strong&gt;t2&lt;/strong&gt;, how can it be overridden in &lt;strong&gt;i5&lt;/strong&gt;, and especially in &lt;strong&gt;i6&lt;/strong&gt;?&lt;br /&gt;This makes so little sense to me, I’m wondering if it’s a compiler error. Does anyone know?&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:26362</id>
    <author>
      <name>jetsnail</name>
    </author>
    <lj:poster user="jetsnail"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/26362.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=26362"/>
    <title>advancedcpp @ 2006-03-24T17:11:00</title>
    <published>2006-03-24T15:17:40Z</published>
    <updated>2006-03-24T16:48:34Z</updated>
    <content type="html">&lt;font size="3"&gt;Today I was asked for simple example of using ADO, C++ and MS SQL Server. I tried to do something understandable, but it is really hard to use ADO in C++.&lt;br /&gt;I have developed solution for this purpose for my company, but it is a set of wrappers for easy using.&lt;br /&gt;I think all of us, who uses ADO in C++, have it's oun unique collection of such libraries :) Am I right? Guys, let's share our experience.&lt;br /&gt;Maybe it would be good to develop some simple and good library that uses ADO as data access library in the heart and upload as GPL to SF.NET.&lt;br /&gt;What you think about it? There is a "simple" example I gave to my friend to enable him to understand how it works :)&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font size="3"&gt;
&lt;a name="cutid1"&gt;&lt;/a&gt;&lt;div class="ljcut" text="Code example"&gt;&lt;font size="3"&gt;// --*-- C++ --*--&lt;br /&gt;//&lt;br /&gt;// The simple C++ example of using Microsoft ADO C++ interface with MS SQL Server.&lt;br /&gt;//&lt;br /&gt;// Copyright (c) 2006 by Vladislav Lazarenko &amp;lt;snail@b2bits.com&amp;gt;&lt;br /&gt;//&lt;br /&gt;// This program is free software; you can redistribute it and/or modify&lt;br /&gt;// it under the terms of the GNU General Public License as published by&lt;br /&gt;// the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;// (at your option) any later version.&lt;br /&gt;//&lt;br /&gt;// This program is distributed in the hope that it will be useful,&lt;br /&gt;// but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&amp;nbsp; See the&lt;br /&gt;// GNU General Public License for more details.&lt;br /&gt;//&lt;br /&gt;// You should have received a copy of the GNU General Public License&lt;br /&gt;// along with this program; if not, write to the Free Software&lt;br /&gt;// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&amp;nbsp; 02110-1301&amp;nbsp; USA&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;#include &amp;lt;exception&amp;gt;&lt;br /&gt;#include &amp;lt;string&amp;gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;#include &amp;lt;boost/noncopyable.hpp&amp;gt;&lt;br /&gt;&lt;br /&gt;#ifndef _ATL_NO_UUIDOF&lt;br /&gt;# define _ATL_NO_UUIDOF&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;#ifndef _WIN32_DCOM&lt;br /&gt;# define _WIN32_DCOM&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;#include &amp;lt;comutil.h&amp;gt;&lt;br /&gt;#include &amp;lt;comdef.h&amp;gt;&lt;br /&gt;#include &amp;lt;comutil.h&amp;gt;&lt;br /&gt;&lt;br /&gt;// NOTE: '$(CommonProgramFiles)\System\ADO' should be used as additional include directory.&lt;br /&gt;#import "msado15.dll" rename("EOF", "EndOfFile")&lt;br /&gt;&lt;br /&gt;/// Unnamed namespace.&lt;br /&gt;namespace&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; /// This class is designed to easy use of COM exception, for example, as std::exception.&lt;br /&gt;&amp;nbsp; /// COM exception is a little bit too hard to manage, enjoy this simple wrapper.&lt;br /&gt;&amp;nbsp; class ComException : public std::exception&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Constructor.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @throw std::exception on errors with COM error description extract.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @param e COM error object.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ComException(const _com_error &amp;amp; e) : std::exception(getErrorDescription(e).c_str()) {}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Destructor.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual ~ComException() {}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Tests the COM operation return code and raise error if something went wrong.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @param res COM operation return code.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @throw ComException if something went wrong.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static void test(HRESULT res)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (FAILED(res))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; issue(res);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Issues the COM error to be raised as ComException.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static void issue(HRESULT res)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _com_issue_error(res);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch(const _com_error &amp;amp; e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw ComException(e);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; private:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Extracts the error description from COM error object.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @param e COM error object.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @return Error description.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static std::string getErrorDescription(const _com_error &amp;amp; e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _bstr_t desc = e.Description();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; std::string::size_type descLen = static_cast&amp;lt;std::string::size_type&amp;gt;(desc.length());&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (descLen &amp;gt; 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return std::string(static_cast&amp;lt;const char *&amp;gt;(desc), descLen);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if (const char *errMsg = e.ErrorMessage())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return errMsg;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Unknown COM error";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; };&lt;br /&gt;&lt;br /&gt;&amp;nbsp; /// To use ADO in C++ we need to initialize COM library.&lt;br /&gt;&amp;nbsp; /// This class designed to easy initialization.&lt;br /&gt;&amp;nbsp; /// @note This class can not be copied. I see no needs in this.&lt;br /&gt;&amp;nbsp; class ComInitializer : private boost::noncopyable&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Constructor.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ComInitializer()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ComException::test(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CoInitializeEx(NULL, COINIT_DISABLE_OLE1DDE | COINIT_SPEED_OVER_MEMORY | COINIT_MULTITHREADED));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Destructor.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ~ComInitializer()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CoUninitialize();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; };&lt;br /&gt;&lt;br /&gt;&amp;nbsp; /// ADO connection object wrapper.&lt;br /&gt;&amp;nbsp; /// As you can understand, using ADO for a long time made me very lazy developer.&lt;br /&gt;&amp;nbsp; /// I am not going to enjoy hard to use Microsoft library, so have written my own wrappers&lt;br /&gt;&amp;nbsp; /// to make life better.&lt;br /&gt;&amp;nbsp; /// This class represents the ADO connection object.&lt;br /&gt;&amp;nbsp; /// @note Connection object can not be basically copied.&lt;br /&gt;&amp;nbsp; ///&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Use shared pointers if you want to share connections.&lt;br /&gt;&amp;nbsp; class Connection : private boost::noncopyable&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Constructor.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @param connectionString ADO connection string to connect to the database.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @note Connection would be established on construction.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @throw ComException on errors.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Connection(const std::string &amp;amp; connectionString)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ComException::test(conn_.CreateInstance(__uuidof(ADODB::Connection)));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ComException::test(conn_-&amp;gt;put_CursorLocation(ADODB::adUseClient));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ComException::test(conn_-&amp;gt;Open(_bstr_t(connectionString.c_str()), L"", L"", ADODB::adConnectUnspecified));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Destructor.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ~Connection()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conn_-&amp;gt;Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch(const _com_error &amp;amp;) {}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Executes the simple SQL statement that does not return the result.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// For more advanced execution refer to the documentation.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @param statement SQL statement to execute.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void executeStatement(const std::string &amp;amp; statement)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADODB::_CommandPtr command;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ComException::test(command.CreateInstance(__uuidof(ADODB::Command)));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; command-&amp;gt;Prepared = false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; command-&amp;gt;PutRefActiveConnection(conn_);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; command-&amp;gt;PutCommandText(_bstr_t(statement.c_str()));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; command-&amp;gt;Execute(NULL, NULL, ADODB::adCmdText | ADODB::adExecuteNoRecords);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch(const _com_error &amp;amp; e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw ComException(e);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; private:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// ADO connection object.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADODB::_ConnectionPtr conn_;&lt;br /&gt;&amp;nbsp; };&lt;br /&gt;&lt;br /&gt;&amp;nbsp; /// Single database access point for the application.&lt;br /&gt;&amp;nbsp; class DataSource : private boost::noncopyable&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; private:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Constructor.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @param connectionString ADO connection string to connect to the database.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @throw ComException on errors.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataSource(const std::string &amp;amp; connectionString) : conn_(connectionString) {}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Destructor.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ~DataSource() {}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// First of all, COM should be initialized.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @note This should be declared first to be initialized before all other.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ComInitializer com_;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Connection used to access the database.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Connection conn_;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Gets the instance of the connection stored in data source.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// @throw ComException on errors.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static Connection &amp;amp; instance()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; static DataSource instance_("Provider=SQLOLEDB;Data Source=(local);initial catalog=Blue;uid=blue;pwd=blue123");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return instance_.conn_;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; };&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/// The entry point of console application.&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; try&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataSource::instance().executeStatement("SELECT GETDATE() AS DATE");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataSource::instance().executeStatement("SELECT GETUTCDATE() AS DATE");&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; catch(const std::exception &amp;amp; e)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; std::cerr &amp;lt;&amp;lt; "ERROR: " &amp;lt;&amp;lt; e.what() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;
&lt;/font&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:25919</id>
    <author>
      <name>jetsnail</name>
    </author>
    <lj:poster user="jetsnail"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/25919.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=25919"/>
    <title>Boost backward compatibility.</title>
    <published>2006-03-23T16:43:23Z</published>
    <updated>2006-03-23T16:43:23Z</updated>
    <content type="html">&lt;font size="3"&gt;Damn, looks like guys from Boost community don't care 'bout backward compatibility. &lt;/font&gt;&lt;font size="3"&gt; It was boost 1.31. Today I have downloaded and installed boost version 1.33. Just two points up but my project won't compile.&amp;nbsp;&lt;/font&gt;&lt;font size="3"&gt;In one of my projects I have simple line of the code to check that two types isn't same. &lt;/font&gt;&lt;font size="3"&gt;Is it so principial, how to write the same code if both ways are easy? As for me - all the same. But why they don't gives a damn 'bout backward compatibility? I don't want to rewrite and recompile my projects each time boost changed :-\&lt;br /&gt; &lt;br /&gt;Was:&lt;br /&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font color="#00ff00"&gt;&lt;br /&gt; &lt;font color="#0000ff"&gt;#include &amp;lt;boost/mpl/assert_is_same.hpp&amp;gt;&lt;br /&gt; &lt;/font&gt;&lt;/font&gt;&lt;boost&gt;&lt;font color="#339966"&gt;&lt;font color="#0000ff"&gt;&lt;br /&gt; ...&lt;br /&gt; &lt;br /&gt; BOOST_MPL_ASSERT_NOT_SAME(T, std::string);&lt;/font&gt;&lt;br /&gt; &lt;/font&gt;&lt;br /&gt;&lt;/boost&gt;&lt;/font&gt;&lt;font size="3"&gt;Now the same thing should be done by the following: &lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;boost&gt;&lt;font color="#0000ff"&gt;#include &lt;/font&gt;&lt;/boost&gt;&lt;font color="#0000ff"&gt;&amp;lt;boost/type_traits/is_same.hpp&amp;gt;&lt;boost&gt;&lt;boost&gt;&lt;br /&gt; #include &lt;/boost&gt;&lt;/boost&gt;&amp;lt;boost/mpl/assert.hpp&amp;gt;&lt;/font&gt;&lt;boost&gt;&lt;boost&gt;&lt;boost&gt;&lt;font color="#0000ff"&gt;&lt;br /&gt; &lt;br /&gt; ...&lt;br /&gt; &lt;br /&gt; &lt;/font&gt;&lt;/boost&gt;&lt;/boost&gt;&lt;/boost&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font color="#0000ff"&gt;BOOST_MPL_ASSERT_NOT((boost::is_same&amp;lt;T, std::string&amp;gt;));&lt;br /&gt; &lt;br /&gt; &lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;boost&gt;&lt;boost&gt;&lt;boost&gt;&lt;/boost&gt;&lt;/boost&gt;&lt;/boost&gt;&lt;/font&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:25854</id>
    <author>
      <name>sethx</name>
    </author>
    <lj:poster user="sethx"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/25854.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=25854"/>
    <title>advancedcpp @ 2006-03-22T15:57:00</title>
    <published>2006-03-22T11:59:52Z</published>
    <updated>2006-03-22T11:59:52Z</updated>
    <content type="html">The D language will soon replace c++. &lt;a href="http://www.digitalmars.com/d/"&gt;http://www.digitalmars.com/d/&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;Dylan as well but sadly marketing needs to take a whole new ball game for that to happen.&lt;br /&gt;&lt;br /&gt;Comments?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:25467</id>
    <author>
      <name>Юля</name>
    </author>
    <lj:poster user="gentleme"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/25467.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=25467"/>
    <title>XML with non-English encoding</title>
    <published>2006-03-19T09:10:46Z</published>
    <updated>2006-03-19T09:10:46Z</updated>
    <content type="html">Does smb know any tip?&lt;br /&gt;When I try to parse XML with greek (for example)  symbols, - I receive ASCII symbols instead of text. &lt;br /&gt;How can I get to parser know encoding? (it is UTF-8).&lt;br /&gt;Thanks in advance!</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:25207</id>
    <author>
      <name>protozoa</name>
    </author>
    <lj:poster user="protozoa"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/25207.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=25207"/>
    <title>advancedcpp @ 2006-03-17T22:49:00</title>
    <published>2006-03-18T03:54:39Z</published>
    <updated>2006-03-18T03:54:39Z</updated>
    <content type="html">I was trying to write a &lt;a href="http://en.wikipedia.org/wiki/Quine"&gt;quine&lt;/a&gt; for C++ but couldn't. I still don't get the trick of &lt;a href="http://www.nyx.net/~gthompso/self_c++.txt"&gt;these&lt;/a&gt;. How do you break the cycle of the self referential loop?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:24871</id>
    <author>
      <name>th1alb</name>
    </author>
    <lj:poster user="th1alb"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/24871.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=24871"/>
    <title>Is the MS Development Environment retarded?</title>
    <published>2006-02-28T22:06:02Z</published>
    <updated>2006-02-28T22:06:02Z</updated>
    <content type="html">I just spent 2 hours on the weirdest problem...&lt;br /&gt;As you might have read in my other post, I am currently writing a C++ program under Linux.&lt;br /&gt;I use putty to compile and run my program on the remote machine but edit the code on my local computer.&lt;br /&gt;When I initially double clicked on the .cpp file, it opened it in Microsoft Development Environment, which I thought would work just fine.&lt;br /&gt;&lt;br /&gt;To make a long storry short, somewhere along the way, I formatted the code and it put all those cool tabs in.&lt;br /&gt;It also put a tab at this spot here:&lt;br /&gt;findobject(totalbuf,found,"submit\"&lt;font style="color: red"&gt;X&lt;/font&gt;value=\"Next \0","\"&amp;gt;\0");&lt;br /&gt;The red x marks what used to be a space and definitely needed to be one for my program to work.&lt;br /&gt;It also looked like a space to me. I was going nuts and didn't know what was wrong until i coincidentally noticed everything jump around after the X when moving the whole line.&lt;br /&gt;&lt;br /&gt;I also have those in other places, where they don't seem to matter that much.&lt;br /&gt;Just wanted to point out what a little stupid &lt;tab&gt; can do to your time.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:24556</id>
    <author>
      <name>Adin</name>
    </author>
    <lj:poster user="tyrdinjer"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/24556.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=24556"/>
    <title>Inheritance with no Virtual Functions?</title>
    <published>2006-02-18T23:28:00Z</published>
    <updated>2006-02-18T23:28:00Z</updated>
    <content type="html">I am working on a C++ wrapper for &lt;a href="http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringRef/index.html?http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html"&gt;CFStringRef&lt;/a&gt; and &lt;a href="http://developer.apple.com/documentation/CoreFoundation/Reference/CFMutableStringRef/index.html?http://developer.apple.com/documentation/CoreFoundation/Reference/CFMutableStringRef/Reference/reference.html"&gt;CFMutableStringRef&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Note, all calls that accept a CFStringRef also accept a CFMutableStringRef.  But any function that requires a CFMutableStringRef will throw an assert() if a mere CFStringRef is passed in.  And no, Apple does not provide a function that lets you test for mutability... :-/&lt;br /&gt;&lt;br /&gt;The life span of these structs are determined by a reference count.  When the count hits zero, they are actually destroyed.  The two functions that increase and decrease the reference count are CFRetain() and CFRelease() respectively.&lt;br /&gt;&lt;br /&gt;The primary purpose of the wrapper classes I am writing is to automatically handle the calls to CFRetain() and CFRelease().&lt;br /&gt;&lt;br /&gt;Making a class to wrap the CFStringRef is straightforward.&lt;br /&gt;&lt;br /&gt;The fun comes into the design for the CFMutableStringRef wrapper class.  If I inherit from the CFStringRef wrapper class, it has these traits:&lt;br /&gt;&lt;br /&gt;1) No additional data fields.&lt;br /&gt;2) All constructors simply call the base class constructors.  They do no additional work.&lt;br /&gt;3) The destructor is empty.  The base class destructor does all necessary work.&lt;br /&gt;4) There are no virtual functions.&lt;br /&gt;&lt;br /&gt;Essentially, the derived class is providing extended functionality.&lt;br /&gt;&lt;br /&gt;So, the big questions is: Do I *need* to worry about at least marking the base destructor as virtual.  &lt;br /&gt;&lt;br /&gt;Or perhaps the better question is: Is there any hidden traps if I don't declare any virtual functions (beyond losing access to the extended member functions should something be upcasted).</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:advancedcpp:24206</id>
    <author>
      <name>th1alb</name>
    </author>
    <lj:poster user="th1alb"/>
    <link rel="alternate" type="text/html" href="http://community.livejournal.com/advancedcpp/24206.html"/>
    <link rel="self" type="text/xml" href="http://community.livejournal.com/advancedcpp/data/atom/?itemid=24206"/>
    <title>brute force</title>
    <published>2006-02-16T02:18:42Z</published>
    <updated>2006-02-16T02:18:42Z</updated>
    <content type="html">Can you guys give me any pointers, on how I would go about writing a html form brute force application in c++?&lt;br /&gt;This would be used to get into the web interface of my dad's router, who apperantly doesn't know the password and can't find where he notated it.&lt;br /&gt;I would like to forward a port to my server, but don't want to reset the router.&lt;br /&gt;&lt;br /&gt;The router is a WR850G (motorola), that has an index.asp with a very simple html form on it.&lt;br /&gt;It shouldn't be too difficult, to write some kind of class, that keeps submitting that form and checks the returned data right?&lt;br /&gt;I would be happy if someone can point me in the right direction or give me any starting points.&lt;br /&gt;&lt;br /&gt;ps: don't worry about passwords; i am just gonna keep counting up the letters basically from 00000000 to ZZZZZZZZ until it fits. I'm on the same LAN, so connection is fast and time is irelevant.&lt;br /&gt;pss: i tried a cuppl programs already, AccessDriver seeming the most sufisticated, but had no success, also those programs require a file with passwords and usernames. i would just like to create those while brute forcing; maybe saving the current possition every 500 passwords or so.&lt;br /&gt;Thx a lot.</content>
  </entry>
</feed>
