FBB::TypeTrait - Type trait class
Contents
Bobcat
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
Bobcat Project Files
o https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
o libbobcat6: debian package containing the shared library, changelog and copyright note;
o libbobcat-dev: debian package containing the static library, headers, manual pages, and developer
info;
Bugs
None Reported.
Copyright
This is free software, distributed under the terms of the GNU General Public License (GPL).
Description
FBB::TypeTrait is a traits class. It does not define any member functions or data members, but merely
types. It can be used to determine the basic type and other characteristics of (const) plain, (const)
pointer or (const) reference types. It was designed after Alexandrescu’s (2001) TypeTraits template
class.
The FBB::LpromotesR class template is used to determine, compile-time, whether its second (right-hand
side) template type can be promoted to its first (left-hand side) template type.
The FBB::Use class template expects two typenames LHS and RHS and defines typenameUse<LHS,RHS>::type as
LHS if RHS can be promoted to LHS or it defines typenameUse<LHS,RHS>::type as RHS.
Examples
Here is an example using LpromotesR:
int main()
{
cout << "string promotes char const *: " <<
LpromotesR<string, char const *>::yes << ’\n’; // 1
cout << "string promotes string " <<
LpromotesR<string, string>::yes << ’\n’; // 1
cout << "char const * promotes string " <<
LpromotesR<char const *, string>::yes << ’\n’; // 0
}
Files
bobcat/typetrait - defines the class interface
Inherits From
-
Lpromotesr<Lefttype, Righttype>
LpromotesR<LeftType,RightType> defines the enum constant yes as 1 if an RightType argument can be
promoted to LeftType value or object. The enum value yes is defined as 0 if no such constructor is
available or if such a constructor is defined using the explicit keyword.
Name
FBB::TypeTrait - Type trait class
Namespace
FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the
namespace FBB.
See Also
bobcat(7)
Alexandrescu A. (2001) ModernC++Design, Addison-Wesley, Boston.
Synopsis
#include<bobcat/typetrait>
Typetrait<Type>
TYPE is the template type parameter whose characteristics must be determined.
TypeTrait<TYPE> defines the type Plain: the plain type (the type without const, pointer, reference type
indication) of any const or non-const plain, pointer, lvalue- or rvalue-reference type.
TypeTrait<TYPE> defines the following bool values:
o isClass: true if the template type argument represents a class (struct) type, false otherwise.
o isConst: true if the template type argument represents a const type, false otherwise.
o isPointer: true if the template type argument represents a pointer type, false otherwise.
o isR_Ref: true if the template type argument represents a rvalue reference type, false otherwise.
o isRef: true if the template type argument represents an lvalue reference type, false otherwise.
