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 β€” true if the template type argument represents a class (struct) type, false otherwise.
  • isConst β€” true if the template type argument represents a const type, false otherwise.
  • isPointer β€” true if the template type argument represents a pointer type, false otherwise.
  • isR_Ref β€” true if the template type argument represents an rvalue reference type, false otherwise.
  • isRef β€” true if the template type argument represents an lvalue reference type, false otherwise.

🌟 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 ⭐

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’. πŸŽ€


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