mirror of https://github.com/ARMmbed/mbed-os.git
Use tag dispatch to better handle both NetworkInterface and NetworkStack pointers. The previous design was intended to avoid ambiguities when presented with a scenario like class MyDevice : public NetworkInterface, public NetworkStack { }; TCPSocket(&MyDevice); // Need NetworkStack *: use NetworkInterface::get_stack or // cast to NetworkStack? But the previous solution didn't actually work as intended. The overload pair nsapi_create_stack(NetworkStack *); // versus template <class IF> nsapi_create_stack(IF *); would only select the first form if passed an exact match - `NetworkStack *`. If passed a derived class pointer, like `MyDevice *`, it would select the template. This meant that an ambiguity for MyDevice was at least avoided, but in the wrong direction, potentially increasing code size. But in other cases, the system just didn't work at all - you couldn't pass a `MyStack *` pointer, unless you cast it to `NetworkStack *`. Quite a few bits of test code do this. Add a small bit of tag dispatch to prioritise the cast whenever the supplied pointer is convertible to `NetworkStack *`. |
||
---|---|---|
.. | ||
test_TCPSocket.cpp | ||
unittest.cmake |