2011-09-20から1日間の記事一覧

std::shared_ptrで動的配列を扱う

C++

std::shared_ptr自体は配列に対する特殊化がなく、boost::shared_arrayも標準では提供されません。 ただ、std::default_deleteは配列に対する特殊化が提供されているので、以下のように書けます。 #include <iostream> #include <memory> #include <string> struct Data { int id; std:</string></memory></iostream>…