Boost logo

Boost Users :

Subject: Re: [Boost-users] Determine at compile time whether type has subtraction semantics?
From: Raymond Burkholder (ray_at_[hidden])
Date: 2011-02-21 11:59:21


> On 19/02/11 06:51, Frédéric Bron wrote:
> >> Is it possible to determine at compile-time if a type has subtraction
> >> semantics? E.g. in struct A<T> I would like to decide at compile-time
not
> to
> >> execute&A::subtract in the register_fns method. Then the subtract
> method is
> >> not instantiated and there is no error.
> Is there any way to do use the type traits to conditionally compile some
> code using some brief syntax? I.e. it would be nice if something like
> the following worked:
>

I think you are looking for something along the lines of what is suggested
"An Optimized Version of std::copy" in the type_traits examples.
http://www.boost.org/doc/libs/1_45_0/libs/type_traits/doc/html/boost_typetra
its/examples/copy.html

It provides conditional compilation via a form of template
indirection/selection.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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