Get rid of BOOST_CONSTEXPR for many signatures until compilers catch up with the expectations of the TS. Define _SCL_SECURE_NO_WARNINGS in test programs to quiet warnings.

This commit is contained in:
Beman 2015-07-15 20:41:24 -04:00
parent 090ab12074
commit 98b24e1406
3 changed files with 43 additions and 35 deletions

View File

@ -117,20 +117,20 @@ namespace boost {
// modifiers // modifiers
void clear() BOOST_NOEXCEPT { len_ = 0; } // Boost extension void clear() BOOST_NOEXCEPT { len_ = 0; } // Boost extension
BOOST_CONSTEXPR void remove_prefix(size_type n) { void remove_prefix(size_type n) {
if ( n > len_ ) if ( n > len_ )
n = len_; n = len_;
ptr_ += n; ptr_ += n;
len_ -= n; len_ -= n;
} }
BOOST_CONSTEXPR void remove_suffix(size_type n) { void remove_suffix(size_type n) {
if ( n > len_ ) if ( n > len_ )
n = len_; n = len_;
len_ -= n; len_ -= n;
} }
/*BOOST_CONSTEXPR*/ void swap(basic_string_view& s) BOOST_NOEXCEPT { void swap(basic_string_view& s) BOOST_NOEXCEPT {
std::swap(ptr_, s.ptr_); std::swap(ptr_, s.ptr_);
std::swap(len_, s.len_); std::swap(len_, s.len_);
} }
@ -166,7 +166,7 @@ namespace boost {
return rlen; return rlen;
} }
BOOST_CONSTEXPR basic_string_view substr(size_type pos, size_type n=npos) const { basic_string_view substr(size_type pos, size_type n=npos) const {
if ( pos > size()) if ( pos > size())
BOOST_THROW_EXCEPTION( std::out_of_range ( "string_view::substr" ) ); BOOST_THROW_EXCEPTION( std::out_of_range ( "string_view::substr" ) );
if ( n == npos || pos + n > size()) if ( n == npos || pos + n > size())
@ -174,25 +174,25 @@ namespace boost {
return basic_string_view ( data() + pos, n ); return basic_string_view ( data() + pos, n );
} }
BOOST_CONSTEXPR int compare(basic_string_view x) const BOOST_NOEXCEPT { int compare(basic_string_view x) const BOOST_NOEXCEPT {
const int cmp = traits::compare ( ptr_, x.ptr_, (std::min)(len_, x.len_)); const int cmp = traits::compare ( ptr_, x.ptr_, (std::min)(len_, x.len_));
return cmp != 0 ? cmp : ( len_ == x.len_ ? 0 : len_ < x.len_ ? -1 : 1 ); return cmp != 0 ? cmp : ( len_ == x.len_ ? 0 : len_ < x.len_ ? -1 : 1 );
} }
BOOST_CONSTEXPR int compare(size_type pos1, size_type n1, basic_string_view x) int compare(size_type pos1, size_type n1, basic_string_view x)
const BOOST_NOEXCEPT { const BOOST_NOEXCEPT {
return substr(pos1, n1).compare(x); return substr(pos1, n1).compare(x);
} }
BOOST_CONSTEXPR int compare(size_type pos1, size_type n1, int compare(size_type pos1, size_type n1,
basic_string_view x, size_type pos2, size_type n2) const { basic_string_view x, size_type pos2, size_type n2) const {
return substr(pos1, n1).compare(x.substr(pos2, n2)); return substr(pos1, n1).compare(x.substr(pos2, n2));
} }
BOOST_CONSTEXPR int compare(const charT* x) const { int compare(const charT* x) const {
return compare(basic_string_view(x)); return compare(basic_string_view(x));
} }
BOOST_CONSTEXPR int compare(size_type pos1, size_type n1, const charT* x) const { int compare(size_type pos1, size_type n1, const charT* x) const {
return substr(pos1, n1).compare(basic_string_view(x)); return substr(pos1, n1).compare(basic_string_view(x));
} }
BOOST_CONSTEXPR int compare(size_type pos1, size_type n1, int compare(size_type pos1, size_type n1,
const charT* x, size_type n2) const { const charT* x, size_type n2) const {
return substr(pos1, n1).compare(basic_string_view(x, n2)); return substr(pos1, n1).compare(basic_string_view(x, n2));
} }
@ -344,7 +344,7 @@ namespace boost {
// Comparison operators // Comparison operators
// Equality // Equality
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator==(basic_string_view<charT, traits> x, inline bool operator==(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
if ( x.size () != y.size ()) return false; if ( x.size () != y.size ()) return false;
return x.compare(y) == 0; return x.compare(y) == 0;
@ -352,7 +352,7 @@ namespace boost {
// Inequality // Inequality
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator!=(basic_string_view<charT, traits> x, inline bool operator!=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
if ( x.size () != y.size ()) return true; if ( x.size () != y.size ()) return true;
return x.compare(y) != 0; return x.compare(y) != 0;
@ -360,7 +360,7 @@ namespace boost {
// Less than // Less than
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator<(basic_string_view<charT, traits> x, inline bool operator<(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return x.compare(y) < 0; return x.compare(y) < 0;
} }
@ -374,63 +374,63 @@ namespace boost {
// Less than or equal to // Less than or equal to
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator<=(basic_string_view<charT, traits> x, inline bool operator<=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return x.compare(y) <= 0; return x.compare(y) <= 0;
} }
// Greater than or equal to // Greater than or equal to
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator>=(basic_string_view<charT, traits> x, inline bool operator>=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return x.compare(y) >= 0; return x.compare(y) >= 0;
} }
// "sufficient additional overloads of comparison functions" // "sufficient additional overloads of comparison functions"
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator==(basic_string_view<charT, traits> x, inline bool operator==(basic_string_view<charT, traits> x,
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT { const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
return x == basic_string_view<charT, traits>(y); return x == basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator==(const std::basic_string<charT, traits, Allocator> & x, inline bool operator==(const std::basic_string<charT, traits, Allocator> & x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) == y; return basic_string_view<charT, traits>(x) == y;
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator==(basic_string_view<charT, traits> x, inline bool operator==(basic_string_view<charT, traits> x,
const charT * y) BOOST_NOEXCEPT { const charT * y) BOOST_NOEXCEPT {
return x == basic_string_view<charT, traits>(y); return x == basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator==(const charT * x, inline bool operator==(const charT * x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) == y; return basic_string_view<charT, traits>(x) == y;
} }
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator!=(basic_string_view<charT, traits> x, inline bool operator!=(basic_string_view<charT, traits> x,
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT { const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
return x != basic_string_view<charT, traits>(y); return x != basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator!=(const std::basic_string<charT, traits, Allocator> & x, inline bool operator!=(const std::basic_string<charT, traits, Allocator> & x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) != y; return basic_string_view<charT, traits>(x) != y;
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator!=(basic_string_view<charT, traits> x, inline bool operator!=(basic_string_view<charT, traits> x,
const charT * y) BOOST_NOEXCEPT { const charT * y) BOOST_NOEXCEPT {
return x != basic_string_view<charT, traits>(y); return x != basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator!=(const charT * x, inline bool operator!=(const charT * x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) != y; return basic_string_view<charT, traits>(x) != y;
} }
@ -460,73 +460,73 @@ namespace boost {
} }
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator>(basic_string_view<charT, traits> x, inline bool operator>(basic_string_view<charT, traits> x,
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT { const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
return x > basic_string_view<charT, traits>(y); return x > basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator>(const std::basic_string<charT, traits, Allocator> & x, inline bool operator>(const std::basic_string<charT, traits, Allocator> & x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) > y; return basic_string_view<charT, traits>(x) > y;
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator>(basic_string_view<charT, traits> x, inline bool operator>(basic_string_view<charT, traits> x,
const charT * y) BOOST_NOEXCEPT { const charT * y) BOOST_NOEXCEPT {
return x > basic_string_view<charT, traits>(y); return x > basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator>(const charT * x, inline bool operator>(const charT * x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) > y; return basic_string_view<charT, traits>(x) > y;
} }
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator<=(basic_string_view<charT, traits> x, inline bool operator<=(basic_string_view<charT, traits> x,
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT { const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
return x <= basic_string_view<charT, traits>(y); return x <= basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator<=(const std::basic_string<charT, traits, Allocator> & x, inline bool operator<=(const std::basic_string<charT, traits, Allocator> & x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) <= y; return basic_string_view<charT, traits>(x) <= y;
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator<=(basic_string_view<charT, traits> x, inline bool operator<=(basic_string_view<charT, traits> x,
const charT * y) BOOST_NOEXCEPT { const charT * y) BOOST_NOEXCEPT {
return x <= basic_string_view<charT, traits>(y); return x <= basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator<=(const charT * x, inline bool operator<=(const charT * x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) <= y; return basic_string_view<charT, traits>(x) <= y;
} }
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator>=(basic_string_view<charT, traits> x, inline bool operator>=(basic_string_view<charT, traits> x,
const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT { const std::basic_string<charT, traits, Allocator> & y) BOOST_NOEXCEPT {
return x >= basic_string_view<charT, traits>(y); return x >= basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits, typename Allocator> template<typename charT, typename traits, typename Allocator>
inline BOOST_CONSTEXPR bool operator>=(const std::basic_string<charT, traits, Allocator> & x, inline bool operator>=(const std::basic_string<charT, traits, Allocator> & x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) >= y; return basic_string_view<charT, traits>(x) >= y;
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator>=(basic_string_view<charT, traits> x, inline bool operator>=(basic_string_view<charT, traits> x,
const charT * y) BOOST_NOEXCEPT { const charT * y) BOOST_NOEXCEPT {
return x >= basic_string_view<charT, traits>(y); return x >= basic_string_view<charT, traits>(y);
} }
template<typename charT, typename traits> template<typename charT, typename traits>
inline BOOST_CONSTEXPR bool operator>=(const charT * x, inline bool operator>=(const charT * x,
basic_string_view<charT, traits> y) BOOST_NOEXCEPT { basic_string_view<charT, traits> y) BOOST_NOEXCEPT {
return basic_string_view<charT, traits>(x) >= y; return basic_string_view<charT, traits>(x) >= y;
} }

View File

@ -7,6 +7,10 @@
For more information, see http://www.boost.org For more information, see http://www.boost.org
*/ */
#ifndef _SCL_SECURE_NO_WARNINGS
# define _SCL_SECURE_NO_WARNINGS
#endif
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <string> #include <string>

View File

@ -7,6 +7,10 @@
For more information, see http://www.boost.org For more information, see http://www.boost.org
*/ */
#ifndef _SCL_SECURE_NO_WARNINGS
# define _SCL_SECURE_NO_WARNINGS
#endif
#include <iostream> #include <iostream>
#include <cstring> // for std::strchr #include <cstring> // for std::strchr