FBB::TypeTrait(3bobcat)
π NAME π
FBB::TypeTrait β the type trait class, bestie π (from the bobcat manual, section 3bobcat if you're keeping score)
β¨ SYNOPSIS β¨
#include <bobcat/typetrait>
π¦ DESCRIPTION π¦
okay so FBB::TypeTrait is a traits class. And when I say traits class I mean it has zero member functions and zero data members β it's literally just types hanging out in there. That's the whole point. It's giving "I'm not like the other classes" energy π
What's it for? Determining the basic type and other characteristics of:
- (const) plain types
- (const) pointer types
- (const) reference types
It was designed after Alexandrescu's (2001) TypeTraits template class. (Yes, we're citing sources. Academic icon behavior π)
The FBB::LpromotesR class template is the one that figures out, at compile time, whether its second (right-hand side) template type can be promoted to its first (left-hand side) template type.
And then there's FBB::Use, which is a class template expecting two typenames LHS and RHS. It spells typename Use<LHS, RHS>::type as LHS if RHS can be promoted to LHS β or, plot twist, it spells typename Use<LHS, RHS>::type as RHS instead. Situation resolved at compile time, no runtime drama π
π NAMESPACE π
FBB
Every constructor, member, operator and manipulator mentioned in this man-page lives in the namespace FBB. All of them. No strays, no cap.
π INHERITS FROM π
-
(nothing. it inherits from nothing. it owes nothing to its ancestors. main character energy fr fr β¨)
π TypeTrait<TYPE> π
TYPE is the template type parameter whose characteristics need to be determined. So basically you hand it a type and it tells you what's tea π΅
TypeTrait<TYPE> defines the type Plain β that's the plain type, aka the type with all the const / pointer / reference indication stripped off. Works for any const or non-const plain, pointer, lvalue-reference or rvalue-reference type. It just gets them all. Slay.
TypeTrait<TYPE> also defines the following bool values:
isClassβtrueif the template type argument represents a class (struct) type,falseotherwise.isConstβtrueif the template type argument represents aconsttype,falseotherwise.isPointerβtrueif the template type argument represents a pointer type,falseotherwise.isR_Refβtrueif the template type argument represents an rvalue reference type,falseotherwise.isRefβtrueif the template type argument represents an lvalue reference type,falseotherwise.
π LpromotesR<LeftType, RightType> π
LpromotesR<LeftType, RightType> defines the enum constant yes as 1 if a RightType argument can be promoted to a LeftType value or object. π
But bestie β 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. Yes, explicit ruins the promotion. We've all been there π
π₯ EXAMPLES π₯
here's an example using LpromotesR, and the comments tell you exactly which answer comes out:
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
}
see how string promotes to char const * and to string, but char const * does NOT promote to string? that's the 0 right there. it's giving directionality. iykyk π
πΈ FILES πΈ
bobcat/typetraitβ defines the class interface
π«Ά SEE ALSO π«Ά
bobcat(7)- Alexandrescu A. (2001) Modern C++ Design, Addison-Wesley, Boston.
π BUGS π
None Reported.
(not me being suspicious of a bug section that says nothing... but okay, we respect it π)
β BOBCAT PROJECT FILES β
- https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
libbobcat6: debian package containing the shared library, changelog and copyright note;libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;
π§ BOBCAT π§
Bobcat is an acronym of `Brokkenβs Own Base Classes And Templatesβ. π
π COPYRIGHT π
This is free software, distributed under the terms of the GNU General Public License (GPL).
π AUTHOR π
Frank B. Brokken (f.b.brokken@rug.nl).
and that's the whole page, bestie π«Ά this one shipped in libbobcat-dev_6.15.01, dated 2005-2026, and yes it really is called FBB::TypeTrait(3bobcat) β go check it, go read it, go use it. mwah π
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms