|
Boost : |
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2002-03-22 02:05:17
You prevent using my<int> ealer in translation unit either.
Gennadiy.
--- Aleksey Gurtovoy <agurtovoy_at_[hidden]> wrote:
>David Abrahams wrote:
>> I'm looking for a legal way to cause certain constructs to fail to
>> compile based on what templates have been instantiated at
>> that point in the program. The catch is that I also want it to be
>> legal to compile the same constructs in other translation units
>> (and, if I have to settle for something permissive, earlier in the
>> same translation unit) where the preventing templates have not
>> been instantiated. Most approaches to this problem result in
>> ODR violations, AFAIK. I'm thinking that there may be
>> some promise in the use of the Barton & Nackmann trick in
>> combination with the unnamed namespace, but I'm not very
>> clear about it.
>> Has anyone already solved this puzzle?
>
>I am not quote sure that I understood your requirements completely, but may
>be something like this:
>
>namespace {
>template< typename T >
>struct disable { typedef T type; };
>}
>
>template< typename T >
>struct my
>{
> my() { typedef typename disable<my>::type t; }
>};
>
>namespace {
>template<> struct disable< my<int> >;
>}
>
>int main()
>{
> my<long> m1; // ok
> my<int> m2; // error
> return 0;
>}
>
>?
>
>Aleksey
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_____________________________________________________________
A free email account your friends will never forget!
Get YOURNAME_at_[hidden] at http://www.emailaccount.com/
_____________________________________________________________
Run a small business? Then you need professional email like you_at_[hidden] from Everyone.net http://www.everyone.net?tag
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk