Quick Links:

bal | bbl | bdl | bsl

Namespaces | Defines

Component bslalg_hastrait
[Package bslalg]

Provide a meta-function to detect if a type has a given trait. More...

Namespaces

namespace  bslalg

Defines

#define bslalg_HasTrait   bslalg::HasTrait

Detailed Description

Outline
Purpose:
Provide a meta-function to detect if a type has a given trait.
Deprecated:
Do not use.
Classes:
bslalg::HasTrait legacy mechanism for detecting type traits
See also:
Component bslalg_typetraits
Description:
This component provides a meta-function, bslalg::HasTrait, that is a legacy mechanism for detecting traits. bslalg::HasTrait takes two template parameters, TYPE and TRAIT, and provides a Type member. bslalg::HasTrait<TYPE, TRAIT>Type evaluates to bslmf::MetaInt<1> if the (template parameter) TYPE has the (template parameter) TRAIT, and to bslmf::MetaInt<0> otherwise. (bslalg::HasTrait also provides a VALUE member where bslalg::HasTrait<TYPE, TRAIT>VALUE evaluates to 1 if the TYPE type has the TRAIT trait, and to 0 otherwise.)
bslalg::HasTrait is not a general-purpose trait detection facility. It is intended to be used in conjunction with the legacy (deprecated) bslalg traits only. In particular, the type supplied to bslalg::HasTrait as the TRAIT template parameter must be a bslalg trait, for example, bslalg::TypeTraitUsesBslmaAllocator. Supplying anything else for TRAIT will (more than likely) fail to compile. For example, the following errant use of bslalg::HasTrait will definitely fail to compile: See bslalg_typetraits for a complete list of the bslalg traits that are supported by bslalg::HasTrait.
In lieu of the deprecated bslalg traits, the newer traits intended to replace them should be used instead. These successor traits are typically defined in bslmf (two exceptions are bslma::UsesBslmaAllocator and bslalg::HasStlIterators). bslalg::HasTrait and the bslalg traits that it supports are written in such a way that bslalg::HasTrait will correctly detect whether a type has a given trait regardless of whether the trait is ascribed to the type using the deprecated BSLALG_DECLARE_NESTED_TRAITS* or BSLMF_NESTED_TRAIT_DECLARATION macros (see bslalg_typetraits and bslmf_nestedtraitdeclaration, respectively), or whether the (preferred) C++11 idiom for defining traits is used (see bslmf_detectnestedtrait). In this way, bslalg::HasTrait provides a "bridge" between legacy bslalg type traits and their replacements that facilitates the migration to the newer traits.
Usage:
No Usage example is provided since this component is deprecated.

Define Documentation

#define bslalg_HasTrait   bslalg::HasTrait