From 9875cfdc9821c44a5e9e49753d2bee34c8d7b299 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 25 Mar 2019 16:17:06 +0200 Subject: [PATCH] Add variant_npos and valueless_by_exception() --- include/boost/variant2/variant.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 3cf2dc1..c109632 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -1,7 +1,7 @@ #ifndef BOOST_VARIANT2_VARIANT_HPP_INCLUDED #define BOOST_VARIANT2_VARIANT_HPP_INCLUDED -// Copyright 2017, 2018 Peter Dimov. +// Copyright 2017-2019 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // @@ -266,6 +266,10 @@ template struct variant_alternative> #endif +// variant_npos + +constexpr std::size_t variant_npos = -1; + // holds_alternative template constexpr bool holds_alternative( variant const& v ) noexcept @@ -1350,6 +1354,11 @@ public: // value status + constexpr bool valueless_by_exception() const noexcept + { + return false; + } + using variant_base::index; // swap