オプションの値を持つマップで shared_ptr を初期化しようとしています。プログラムの後の段階で値を初期化します。
次の投稿を読み、ガイドとして使用しました: std::map に値を指定せずに有効なキーを追加する方法は?
しかし、shared_ptr を使用しているため、私の状況は少し異なります。これ以上苦労することなく、これは私が書いたコードです:
ShaderProgram.h
...
#include <map>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
typedef map<string, optional<GLuint> > attributes_map;
class ShaderProgram
{
public:
ShaderProgram(vector<string> attributeList);
...
private:
shared_ptr<attributes_map> attributes;
};
ShaderProgram.mm
ShaderProgram::ShaderProgram(vector<string> attributeList)
{
// Prepare a map for the attributes
for (vector<string>::size_type i = 0; i < attributeList.size(); i++)
{
string attribute = attributeList[i];
attributes[attribute];
}
}
コンパイラから次のエラーが通知されます: タイプ 'shared_ptr' は添字演算子を提供していません。
誰でも何が問題なのか考えていますか?