2
나는 솔루션부스트 람다 예를
enum Opcode {
OpFoo,
OpBar,
OpQux,
};
// this should be a pure virtual ("abstract") base class
class Operation {
// ...
};
class OperationFoo: public Operation {
// this should be a non-abstract derived class
};
class OperationBar: public Operation {
// this should be a non-abstract derived class too
};
std::unordered_map<Opcode, std::function<Operation *()>> factory {
{ OpFoo, []() { return new OperationFoo; } }
{ OpBar, []() { return new OperationBar; } }
{ OpQux, []() { return new OperationQux; } }
};
Opcode opc = ... // whatever
Operation *objectOfDynamicClass = factory[opc]();
그러나 불행하게도 내 컴파일러 GCC-4.4.2 람다 기능을 지원하지 않습니다의 일환으로 만든지도가 있습니다.
내가 는 C에서 ++ 표준을 스 네크 어떤 방법이 있나요이 사용 부스트 라이브러리 (읽기) 구현 (람다/피닉스) 대체하고 싶습니다:;. 내 컴파일러 -std에 람다 및 표준 : : 기능