diff options
| author | William A. Kennington III <wak@google.com> | 2018-10-12 18:04:32 -0700 |
|---|---|---|
| committer | William A. Kennington III <wak@google.com> | 2018-10-15 22:59:46 +0000 |
| commit | b20866d311e15098cfdd523cc9df9df9972abd0b (patch) | |
| tree | ca5396091b02b7e04056571e2a98a61ff49001d6 | |
| parent | 47b31887ae0ab92f8b92ad78d0a41fe94e08317b (diff) | |
| download | sdbusplus-b20866d311e15098cfdd523cc9df9df9972abd0b.tar.gz sdbusplus-b20866d311e15098cfdd523cc9df9df9972abd0b.zip | |
mapbox/variant: Add std::visit compatible function
mapbox used to require that we use the apply_visitor interface. The new
std::variant std::visit() interface is more generic and a superset of the
functionality provided by apply_visitor. We just need to provide an
alias.
Tested:
Used this in phosphor-host-ipmid with a work in progress commit to
make sure the compat layer is working fully.
Change-Id: I6ca9747e4f0825220e47bb9b2965a249466b3593
Signed-off-by: William A. Kennington III <wak@google.com>
| -rw-r--r-- | mapbox/variant.hpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mapbox/variant.hpp b/mapbox/variant.hpp index 9f039bc..7c02032 100644 --- a/mapbox/variant.hpp +++ b/mapbox/variant.hpp @@ -1079,6 +1079,14 @@ auto VARIANT_INLINE apply_visitor(F&& f, V& v0, V& v1) return V::binary_visit(v0, v1, std::forward<F>(f)); } +// Needed for compatibility with std::variant +template <typename... Args> +constexpr auto visit(Args&&... args) + -> decltype(apply_visitor(std::forward<Args>(args)...)) +{ + return apply_visitor(std::forward<Args>(args)...); +} + // is interface #ifdef HAS_EXCEPTIONS |

