Why is Boost.Any an application of Adapter pattern?

66 views Asked by At

Why is Boost.Any an application of the Adapter pattern? Who would be the Adaptee? I'm confused. Thanks!

1

There are 1 answers

0
sehe On

Who claims as much? An adaptor "adapts" the public interface to another. Arguably, Any just removes the interfaces "hiding" it.

Of course a minimum interface is substituted that allows users to recover the "original", underlying interface.

But I wouldn't call that adaptation. For adaptation, I'd expect to have a useful interface indirectly mapped onto another interface implementation.


Oh, and in

boost::any any = std::string("hello world");

the std::string object would be the adaptee. But that's presuming that you agree that it "adapts" the string to an "any" interface