|
Boost : |
Subject: Re: [boost] [type_traits] is_complete<T> possible realization
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2012-11-05 05:52:35
2012/11/5 John Maddock <boost.regex_at_[hidden]>:
> I don't have an answer to your question, except this has been suggested
> before - and got shot down because the definition of is_complete<T> would
> need to change depending where it was instantiated - and you can't do that
> (one definition rule).
Searching for is_complete in Internet gave me a non-compiling function
that even in theory can not work with abstract classes.
In my proposal ODR is bypassed by the set of 'Misc' parameters:
template <class T, class T1, class T2, class T3>
void test_function() {
// Parameters after T are used to cheat on ODR
is_complete<T, T1, T2, T3, boost::mpl::int_<__LINE__> >::value;
}
> BTW if all you want is an assertion that a type is complete then:
>
> BOOST_STATIC_ASSERT(sizeof(T));
>
> would do the trick.
That is exactly what I`m trying not to do:
template <bool IsAwailable>
struct stl_specific_work{
static void act() {
throw std::logic_error("Attempt to use ctype<char16_t> for non
'C' locale: your STL implementation does not specialize
ctype<char16_t>");
}
};
template <>
struct stl_specific_work<true>{
static void act() {
// Some work with ctype<char16_t>
}
};
if (std::locale() != std::locale::classic()) {
stl_specific_work<
!is_complete<ctype<char16_t> /*, SomeMoreTemplateParameters*/ >::value
>::act();
}
I need to work with ctype<char16_t> if it is available. Without
is_complete<> I would be required to forbid ctype<char16_t> usage even
on platforms that do support it and even if user provided it`s own
implementation.
-- Best regards, Antony Polukhin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk