|
Boost Users : |
From: Parag Gadkari (parag.gadkari_at_[hidden])
Date: 2006-05-22 13:48:13
AFAIK, VC7 does not fill in the default argument for templated types.
I remember a solution posted by Dave Abrahams in some(?) forum, wherein he
used one of boost library to acheive this, but I don't remember the exact
solution and library.
I used an extra level of indirection, but I can not assure you if this is
anywhere near standard practices only the gurus can...
Here is what I did:
////////////////////////////////////////////////////////////////
BOOST_MPL_HAS_XXX_TRAIT_DEF(ctype)
///// SomeFunc function///////////////
template <typename T, class Cont>
typename Cont::ctype somefunc(T a, typename p_enable_if<has_ctype<Cont>,
typename Cont::ctype > *p =0) {
Cont::ctype c;
c.push_back(a);
return c;
}
//////Container wrap
template <
typename _elem,
template<
typename Elem,
typename Alloc=std::allocator<Elem>
>
class cont,
typename Alloc=std::allocator<_elem>
>
struct _container {
typedef cont<_elem,Alloc> ctype;
};
int _tmain(int argc, _TCHAR* argv[]) {
...
std::vector<char> cd = somefoo<char, _container<char,std::vector> >('a');
...
}
On 5/18/06, chun ping wang <cablepuff_at_[hidden] > wrote:
>
> the error is on "CONT<T> someFunc()"...
>
> On 5/18/06, Michael Rickert < pandamojo_at_[hidden]> wrote:
>
> > DevC++ uses GCC, and 4.0.0 seems to grok that, although I might be
> instantiating it differently (since you didn't post the line triggering the
> error).
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
-- "Civilization is the limitless multiplication of unnecessary necessities." -- Mark Twain
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net