$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Sean Huang (huangsean_at_[hidden])
Date: 2006-03-30 12:04:03
I noticed that a few boost libraries use std::basic_string differently. For
example, boost::program_options uses it like this:
template<class T, class charT>
void validate(boost::any& v,
const std::vector< std::basic_string<charT> >& xs,
T*, long);
And string_algorithm uses the following instead:
template<
typename SequenceT,
typename CharT,
typename RegexTraitsT,
typename FormatStringTraitsT, typename FormatStringAllocatorT >
inline void replace_all_regex(
SequenceT& Input,
const basic_regex<CharT,
RegexTraitsT>& Rx,
const
std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>&
Format,
match_flag_type
Flags=match_default | format_default );
The standard says std::basic_string has 3 template parameters (two have
defaults). Usages like std::basic_string<charT> would prevent the matching
of non-standard traits or allocators. And in the case of program_options, my
overload with 3 template parameters actually caused an ambiguity with one
defined in program_options:
My overload:
template< class CharType, class Traits, class Alloc >
void validate( boost::any& v,
const std::vector< std::basic_string< CharType, Traits,
Alloc > >& xs,
unsigned long*, long )
Defined in program_options:
template<class T, class charT>
void validate(boost::any& v,
const std::vector< std::basic_string<charT> >& xs,
T*, long)
My question is if the differences in usage is justified or just an oversight
and what the recommendation is?
Thanks,
Sean