Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么 Boost.Any 是适配器模式的应用程序?谁将成为适应者?我很困惑。谢谢!
谁声称这么多?一个适配器将公共接口“适配”到另一个。可以说, Any 只是删除了“隐藏”它的接口。
当然,一个最小接口被替换,允许用户恢复“原始”的底层接口。
但我不会称之为适应。为了适应,我希望有一个有用的接口间接映射到另一个接口实现。
哦,在
boost::any any = std::string("hello world");
std::string对象将是被适配者。但这是假设您同意它将字符串“调整”到“任何”接口
std::string