From 38b536ff05c53b23187a53f8d3b5a259475d91ad Mon Sep 17 00:00:00 2001 From: Surogate Date: Mon, 12 Dec 2016 22:57:56 +0100 Subject: [PATCH] Fixing visual studio compilation of string_view::at() VS2013, VS2015 & VS2017RC don't like the ternary throwing an exception : 'return': cannot convert from 'void' to 'const char &' Now using classic if when compiling on a windows platform. --- include/boost/utility/string_view.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/boost/utility/string_view.hpp b/include/boost/utility/string_view.hpp index 167b30c..f49d12c 100644 --- a/include/boost/utility/string_view.hpp +++ b/include/boost/utility/string_view.hpp @@ -121,10 +121,13 @@ 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]; -// if ( pos >= len_ ) -// BOOST_THROW_EXCEPTION( std::out_of_range ( "boost::string_view::at" ) ); -// return ptr_[pos]; +#else + if (pos >= len_) + BOOST_THROW_EXCEPTION(std::out_of_range("boost::string_view::at")); + return ptr_[pos]; +#endif } BOOST_CONSTEXPR const_reference front() const { return ptr_[0]; }