<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>smart pointer for unsigned char[]? - C++ - tribe.net</title>
    <link>http://cpp.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4?format=rss</link>
    <description>Tribe.net. Local Connections</description>
    <item>
      <title>Re: smart pointer for unsigned char[]?</title>
      <link>http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#95e5e6a8-024e-4815-8e31-59695092136f</link>
      <description>Just out of curiosity why didnt you do this:&#xD;
&#xD;
boost::scoped_array&amp;amp;lt;unsigned char&gt;pBuf(new unsigned char[512 *1024]);&#xD;
&#xD;
You said you were needing an array of unsigned chars, not unsigned char *&#xD;
and if scoped_array doesnt work (it has some limitations)&#xD;
try shared_array (also in boost).&#xD;
Perhaps I just didnt fully understand you implementation but it seems to me if you change your statement it will do what you want.&#xD;
&#xD;
I have only been using boost a very short time, but I tell you I am sold on it, also be very careful with vectors under certain conditions the pointers, references and iterators can be invalidated without your realizing it. I used to be sold on vectors, now I find other containers more to my liking ;-) to each his own.</description>
      <pubDate>Sat, 15 Jul 2006 19:14:37 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#95e5e6a8-024e-4815-8e31-59695092136f</guid>
      <dc:creator>Steve</dc:creator>
      <dc:date>2006-07-15T19:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: smart pointer for unsigned char[]?</title>
      <link>http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#1b96d20a-f250-48c4-b897-2ec0ea3575a7</link>
      <description>&amp;amp;v[0] is the pointer to the beginning, as is &amp;amp;*v.begin(). v.begin() itself is not guaranteed to be a pointer, and it many implementations it is not.&#xD;
&#xD;
For more information, read Effective STL.</description>
      <pubDate>Mon, 19 Jun 2006 02:13:40 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#1b96d20a-f250-48c4-b897-2ec0ea3575a7</guid>
      <dc:creator>Ben</dc:creator>
      <dc:date>2006-06-19T02:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: smart pointer for unsigned char[]?</title>
      <link>http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#1123ab22-926f-40ef-8a37-13a7c7bbd60a</link>
      <description>It'll work fine, std::vector::begin() is your unsigned char pointer.</description>
      <pubDate>Mon, 19 Jun 2006 02:04:09 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#1123ab22-926f-40ef-8a37-13a7c7bbd60a</guid>
      <dc:creator>Scott</dc:creator>
      <dc:date>2006-06-19T02:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: smart pointer for unsigned char[]?</title>
      <link>http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#fae6aa19-8377-439b-88aa-4d2a1283a780</link>
      <description>Scott,&#xD;
&#xD;
Yes, I also consider a vector, but I need to mix this (for now) with old C-style APIs like fread / fwrite, which expect unsigned char pointers.  Will std::vectors' ++ and [] operators "fool" fread / fwrite into thinking that they're dealing with an unsigned char *?  I don't know -- I guess it's something to experiment with :-)&#xD;
&#xD;
Regards,&#xD;
&#xD;
John&#xD;
&#xD;
Falling You - exploring the beauty of voice and sound&#xD;
http://www.fallingyou.com</description>
      <pubDate>Mon, 19 Jun 2006 01:51:30 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#fae6aa19-8377-439b-88aa-4d2a1283a780</guid>
      <dc:creator>John Michael</dc:creator>
      <dc:date>2006-06-19T01:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: smart pointer for unsigned char[]?</title>
      <link>http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#e417f990-9015-4e8a-8937-c508397e7cd7</link>
      <description>std::vector&amp;amp;lt;unsigned char&gt;</description>
      <pubDate>Mon, 19 Jun 2006 01:30:54 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#e417f990-9015-4e8a-8937-c508397e7cd7</guid>
      <dc:creator>Scott</dc:creator>
      <dc:date>2006-06-19T01:30:54Z</dc:date>
    </item>
    <item>
      <title>smart pointer for unsigned char[]?</title>
      <link>http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#f8a5f244-f0fe-4705-9777-028fbeff5ee3</link>
      <description>Hello, all ...&#xD;
&#xD;
I want to use a smart pointer, preferably boosty, to encapsulate an array of unsigned chars that I need to allocate from the heap:&#xD;
&#xD;
int main()&#xD;
{&#xD;
    unsigned char *pBuf = new unsigned char[ 512 * 1024 ];    // icky, this isn't quite smart enough :-)&#xD;
&#xD;
    auto_ptr&amp;lt; unsigned char * &gt; pBuf( new unsigned char[ 512 * 1024 ] );  // no work, auto_ptr dtor does not call delete[]&#xD;
&#xD;
    boost::scoped_array&amp;lt; unsigned char *&gt; pBuf( new unsigned char[ 512 * 1024 ] );  // no work, boost expect an array of unsigned char pointers here, not an array of unsigned chars&#xD;
&#xD;
    // the thing I kinda need to do is ...&#xD;
&#xD;
    fread( pBuf, 1, lotsa_bytes, pFile ); &#xD;
}&#xD;
&#xD;
... any hints?  I'm not new to smart pointers, but I am kinda new to boost ...&#xD;
&#xD;
Regards,&#xD;
&#xD;
John&#xD;
&#xD;
Falling You - exploring the beauty of voice and sound&#xD;
http://www.fallingyou.com</description>
      <pubDate>Mon, 19 Jun 2006 00:13:24 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/71df2db6-9882-49c0-b811-980f21e520e4#f8a5f244-f0fe-4705-9777-028fbeff5ee3</guid>
      <dc:creator>John Michael</dc:creator>
      <dc:date>2006-06-19T00:13:24Z</dc:date>
    </item>
  </channel>
</rss>



