Upgrade to Pro — share decks privately, control downloads, hide ads and more …

C++の話(本当にあった怖い話)

 C++の話(本当にあった怖い話)

Python hack-a-thon 2010.07

用資料です。

Yuki Tamura

July 12, 2010
Tweet

More Decks by Yuki Tamura

Other Decks in Programming

Transcript

  1. #include <iostream> #include <algorithm> #include <boost/array.hpp> using namespace std; //

    letsboostΑΓ int main() { boost::array<int, 100> ar; // int ar[100]; for( int i=0; i<ar.size(); ++i ) ar[i] = i * 100; boost::array<int, 4> ar2 = {{0, 100, 200, 300}}; if( equal( ar2.begin(), ar2.end(), ar.begin() ) ) cout << "same" << endl; return 0; } Ͱ͸ɺboost::arrayΛಡΉ 2010೥7݄10೔౔༵೔
  2. /* The following code declares class array, * an STL

    container (as wrapper) for arrays of constant size. * * See * http://www.boost.org/libs/array/ * for documentation. * * The original author site is at: http://www.josuttis.com/ * * (C) Copyright Nicolai M. Josuttis 2001. * * Distributed under the Boost Software License, Version 1.0. (See * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. * See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168 * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow) * 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow) * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis) * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries. * 05 Aug 2001 - minor update (Nico Josuttis) * 20 Jan 2001 - STLport fix (Beman Dawes) * 29 Sep 2000 - Initial Revision (Nico Josuttis) * * Jan 29, 2004 */ #ifndef BOOST_ARRAY_HPP #define BOOST_ARRAY_HPP #include <boost/detail/workaround.hpp> #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) # pragma warning(push) # pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe # pragma warning(disable:4510) // boost::array<T,N>' : default constructor could not be generated # pragma warning(disable:4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constru required #endif #include <cstddef> #include <stdexcept> #include <boost/assert.hpp> #include <boost/swap.hpp> 2010೥7݄10೔౔༵೔
  3. $ ͷ࿩͡Όͳ͍ͷʁ Զɺ࠷ۙ$ ॻ͍ͯͳ͍Μͩ|| Ͱɺ$ ͷݴޠతͳ࿩Λͯ͠΋ͳ͋|| 1ZUIPO޷͖ͳΈΜͳ͸$ ͱ͔Ͳ͏Ͱ΋͍͍ΑͶ ͔ͤͬ͘ͳͷͰɺා͍࿩Ͱ΋͠·͢ ͱ͍͏͜ͱͰຊ౰ʹ͋ͬͨා͍࿩Ͱ͢

    σΟʔϓͳ$ ͷ࿩ͱ͔$ Yʢ࣍ظඪ४ʣͷ࿩ͱࢥͬ ͨਓ͝ΊΜͳ͍͞ ͦ͏͍͏ਓ͸#PPTUษڧձʹͰ΋ߦ͍ͬͯͩ͘͞ 2010೥7݄10೔౔༵೔
  4. ΦϨΦϨίϯςφ͔͠ ৴͡ͳ͍༓ྶ 45- ඪ४ϥΠϒϥϦ ΍#PPTU ඪ४Խҕ һձ͕த৺ͱͳͬͨ044 ͸ʮ৴༻Ͱ͖ ͳ͍ʯͷͰɺࣗ෼Ͱॻ͍ͨίϯςφ͔͠ ࢖Θͳ͍ͱ͍͏ਓ͕͍Δ

    ඪ४Λ࢖͑͹ͱ͍͏ͱ͙͢ʮόάͬͯΔͩ Ζʁʯͱ͔ʮόάͬͯͨΒ৺഑ʯͱ͔ݴ͏ ࣗ෼͕࡞ͬͨίϯςφ͔͠࢖Θͳ͍ͷͰ ޓ׵ੑ̌ɺΠϯλʔϑΣΠε΋ແ஡ۤ஡ 1ZUIPOͰྫ͑ΔͱMJTU΍EJDU͕ࣗ࡞ 2010೥7݄10೔౔༵೔