From 38121f2af336fc7b081752d19c70660a90722fe5 Mon Sep 17 00:00:00 2001 From: Surogate Date: Mon, 12 Dec 2016 23:45:34 +0100 Subject: [PATCH] Allow string_view::at() to be constexpr again on VS2015 VS2015 doesn't support extended constexpr. Thanks to Lastique for the ternary trick --- include/boost/utility/string_view.hpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/include/boost/utility/string_view.hpp b/include/boost/utility/string_view.hpp index f49d12c..410bd88 100644 --- a/include/boost/utility/string_view.hpp +++ b/include/boost/utility/string_view.hpp @@ -121,13 +121,7 @@ namespace boost { BOOST_CONSTEXPR const_reference operator[](size_type pos) const BOOST_NOEXCEPT { return ptr_[pos]; } BOOST_CONSTEXPR const_reference at(size_t pos) const { -#ifndef _MSC_VER - return pos >= len_ ? BOOST_THROW_EXCEPTION(std::out_of_range("boost::string_view::at")) : ptr_[pos]; -#else - if (pos >= len_) - BOOST_THROW_EXCEPTION(std::out_of_range("boost::string_view::at")); - return ptr_[pos]; -#endif + return pos >= len_ ? BOOST_THROW_EXCEPTION(std::out_of_range("boost::string_view::at")), ptr_[0] : ptr_[pos]; } BOOST_CONSTEXPR const_reference front() const { return ptr_[0]; }