本文整理汇总了C++中sprout::basic_string类的典型用法代码示例。如果您正苦于以下问题:C++ basic_string类的具体用法?C++ basic_string怎么用?C++ basic_string使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了basic_string类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: string_to_int_dynamic
inline IntType
string_to_int_dynamic(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx, int base = 10) {
Elem* endptr = nullptr;
IntType result = sprout::detail::str_to_int<IntType>(str.c_str(), &endptr, base);
*idx = endptr - str.c_str();
return result;
}
示例2:
inline SPROUT_CONSTEXPR sprout::basic_string<T, N1 + N2, Traits>
operator+(sprout::basic_string<T, N1, Traits> const& lhs, sprout::basic_string<T, N2, Traits> const& rhs) {
return sprout::detail::string_concat(
lhs, lhs.size(),
rhs, rhs.size(),
sprout::make_index_tuple<N1 + N2>::make()
);
}
示例3: const
inline SPROUT_CONSTEXPR sprout::basic_string<T, (M - 1) + N, Traits>
operator+(T const (& lhs)[M], sprout::basic_string<T, N, Traits> const& rhs) {
return sprout::detail::string_concat(
lhs, sprout::char_traits<T>::length(lhs),
rhs, rhs.size(),
sprout::index_range<0, (M - 1) + N>::make()
);
}
示例4:
inline SPROUT_CONSTEXPR sprout::basic_string<T, N, Traits>
operator>>(sprout::basic_string<T, N, Traits> const& lhs, T const* rhs) {
return sprout::detail::string_lshift(
lhs, lhs.size(),
rhs, Traits::length(rhs),
sprout::make_index_tuple<N>::make()
);
}
示例5:
inline SPROUT_CONSTEXPR sprout::basic_string<T, 1 + N, Traits>
operator+(T const& lhs, sprout::basic_string<T, N, Traits> const& rhs) {
return sprout::detail::string_concat(
lhs,
rhs, rhs.size(),
sprout::index_range<0, 1 + N>::make()
);
}
示例6: const
inline SPROUT_CONSTEXPR sprout::basic_string<T, (M - 1) + N, Traits>
operator+(T const (& lhs)[M], sprout::basic_string<T, N, Traits> const& rhs) {
typedef sprout::char_traits_helper<Traits> traits_type;
return sprout::detail::string_concat(
lhs, traits_type::length(lhs, M - 1),
rhs, rhs.size(),
sprout::make_index_tuple<(M - 1) + N>::make()
);
}
示例7: if
inline SPROUT_NON_CONSTEXPR std::basic_istream<T, StreamTraits>&
operator>>(std::basic_istream<T, StreamTraits>& lhs, sprout::basic_string<T, N, Traits>& rhs) {
typedef T elem_type;
typedef StreamTraits traits_type;
typedef std::basic_istream<T, StreamTraits> istream_type;
typedef sprout::basic_string<T, N, Traits> string_type;
typedef std::ctype<elem_type> ctype_type;
typedef typename string_type::size_type size_type;
std::ios_base::iostate state = std::ios_base::goodbit;
bool changed = false;
size_type current = 0;
if (typename istream_type::sentry(lhs)) {
ctype_type const& ctype_fac = std::use_facet<ctype_type>(lhs.getloc());
try {
size_type remain = 0 < lhs.width() && static_cast<size_type>(lhs.width()) < rhs.max_size()
? static_cast<size_type>(lhs.width())
: rhs.max_size()
;
typename traits_type::int_type meta = lhs.rdbuf()->sgetc();
for (; remain; --remain, meta = lhs.rdbuf()->snextc())
if (traits_type::eq_int_type(traits_type::eof(), meta)) {
state |= std::ios_base::eofbit;
break;
} else if (ctype_fac.is(ctype_type::space, traits_type::to_char_type(meta))) {
break;
} else {
rhs[current] = traits_type::to_char_type(meta);
changed = true;
++current;
}
} catch (...) {
state |= std::ios_base::badbit;
}
}
lhs.width(0);
if (!changed) {
state |= std::ios_base::failbit;
}
lhs.setstate(state);
rhs.resize(current);
return lhs;
}
示例8: string_to_float_dynamic
inline FloatType string_to_float_dynamic(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx) {
Elem* endptr = nullptr;
FloatType result = sprout::detail::str_to_float<FloatType>(str.c_str(), &endptr);
*idx = endptr - str.c_str();
return result;
}
示例9: string_to_int
inline SPROUT_CONSTEXPR IntType
string_to_int(sprout::basic_string<Elem, N, Traits> const& str, int base = 10) {
return sprout::detail::str_to_int<IntType>(str.begin(), base);
}
示例10:
inline SPROUT_CONSTEXPR bool
operator<(sprout::basic_string<T, N, Traits> const& lhs, T const* rhs) {
return lhs.compare(rhs) < 0;
}
示例11: hash_value
inline SPROUT_CONSTEXPR std::size_t hash_value(sprout::basic_string<T, N, Traits> const& v) {
return sprout::hash_range(v.begin(), v.end());
}
示例12: string_to_float
inline SPROUT_CONSTEXPR FloatType
string_to_float(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx) {
return !idx ? sprout::detail::str_to_float<FloatType>(str.begin())
: sprout::detail::string_to_float_dynamic<FloatType>(str, idx)
;
}