Skip to main content

Types in xtd

  • By design xtd has defined its own types which are only ever aliases to the fixed integer types of c++.
  • You are not obliged to use the xtd types, you are even encouraged to use the standard types or those you want.
  • The xtd defines unboxed and boxed types listed below. The unboxed types is same as the native type. The boxed type is an xtd::box inherited from xtd::object.


For more performance prefere used unboxed type. Used boxed type when necessary, e.g., to parse, polymorphism, ...

Types list

Unboxed typeBoxed typeC++11 type C++ standard typeSize in bytesValue
boolxtd::boolean_objectboolbool1Represents a boolean value.
char xtd::char_objectcharchar1Represents a characters.
xtd::char8 xtd::char8_objectchar8_tchar1Represents a unicode characters.
xtd::char16 xtd::char16_objectchar16_tshort2Represents a unicode characters.
xtd::char32 xtd::char32_objectchar32_tint4Represents a unicode characters.
xtd::wchar xtd::wchar_objectwchar_tshort - or - int (1)2 - or - 4 (1)Represents a unicode characters.
xtd::bytextd::byte_objectuint_least8_tunsigned char1Represents a 8-bit unsigned integer.
xtd::int16xtd::int16_objectint_least16_tshort2Represents a 16-bit signed integer.
xtd::int32xtd::int32_object int_least32_tint4Represents a 32-bit signed integer.
xtd::int64xtd::int64_objectint_least64_tlong long.8Represents a 64-bit signed integer.
 xtd::intptrxtd::intptr_objectintmax_tint - or - long long (2)4 - or - 8 (2)Represent a pointer or a handle.
xtd::sbytextd::sbyte_objectint_least8_tchar 1Represents a 8-bit signed integer.
xtd::uint16xtd::uint16_objectuint_least16_t unsigned short2Represents a 16-bit unsigned integer.
xtd::uint32xtd::uint32_objectuint_least32_tunsigned int4 Represents a 32-bit unsigned integer.
xtd::uint64xtd::uint64_object uint_least64_tunsigned long long 8Represents a 64-bit unsigned integer.
xtd::uintptrxtd::uintptr_objectuintmax_tunsigned int - or - unsigned long long (2)4 - or - 8 (2)Represent an unsigned pointer or a handle.
 xtd::singlextd::single_objectfloatfloat 4Represents a single-precision floating-point number.
doublextd::double_objectdoubledouble8Represents a double-precision floating-point number.
xtd::decimal (3)xtd::decimal_objectlong double (3)long double (3)8 - or -16 (3)Represents a double-precision floating-point number.
xtd::sizextd::size_objectsize_tresult of the sizeof operator (2)4 - or - 8 (2)Represent an unsigned pointer or a handle.
xtd::date_timextd::date_time//8Represents an instant in time, typically expressed as a date and time of day.
const char*xtd::ustring std::string std::string (4)variableRepresents text as a series of unicode characters.

(1) Depend of OS : if build on Windows is 2 bytes, if build on Linux or many other non-Windows systems is 4 bytes.

(2) Depend of build : if build in 32 bits the size is 4 bytes, if build in 64 bits the size is 8 bytes.

(3) xtd::decimal is an extended precision floating-point type. Matches IEEE-754 binary128 format if supported, otherwise matches IEEE-754 binary64-extended format if supported, otherwise matches some non-IEEE-754 extended floating-point format as long as its precision is better than binary64 and range is at least as good as binary64, otherwise matches IEEE-754 binary64 format.

  • binary128 format is used by some HP-UX, SPARC, MIPS, ARM64, and z/OS implementations.
  • The most well known IEEE-754 binary64-extended format is 80-bit x87 extended precision format. It is used by many x86 and x86-64 implementations (a notable exception is MSVC, which implements long double in the same format as double, i.e. binary64).

(4) The std::string type is the main string datatype in standard C++ since 1998, but it was not always part of C++98.

For more information about c++ type see cppreference language type section.

For the complete list of xtd types see xtd - Referecne Guide - types section.


xtd define the minimum and maximum constant value for each types.

TypeMinimum ValueMaximum ValueMinimum ValueMaximum Value
 xtd::boolean_objectxtd::boolean_object::min_valuextd::boolean_object::max_value falsetrue
xtd::int32_objectxtd::int32_object::min_value xtd::int32_object::max_value -21474836482147483647
xtd::int64_object xtd::int64_object::min_valuextd::int64_object::max_value-9223372036854775808 9223372036854775807
xtd::sbyte_objectxtd::sbyte_object::min_value xtd::sbyte_object::max_value -128 127
 xtd::uint16_objectxtd::uint16_object::min_value xtd::uint16_object::max_value 0 65535
xtd::uint32_objectxtd::uint32_object::min_value xtd::uint32_object::max_value04294967295
 xtd::uint64_objectxtd::uint64_object::min_value xtd::uint64_object::max_value 018446744073709551615
xtd::single_objectxtd::single_object::min_valuextd::single_object::max_value-3.40282e+038f 3.40282e+038f
xtd::date_timextd::date_time::min_valuextd::date_time::max_value00:00:00, January 1, 000123:59:59, December 31, 9999


Of course, std::numeric_limits works for the types described above except for xtd::date_time.


For explicit boxing a type into corresponding object class use xtd::boxing method. By default, the boxing implicit in the corresponding object is used.

bool value_unboxed = true;
xtd::boolean_object value_boxed1 = value_unboxed; // implicit
xtd::boolean_object value_boxed2 = xtd::boxing(value_unboxed); // explicit
auto ready_boxed3 = xtd::boxing(value_unboxed); // explicit with auto is xtd::boolean_object type


For explicit unboxing a object class into corresponding type use xtd::unboxing method. By default, the unboxing implicit in the corresponding type is used.

xtd::boolean_object value_boxed = true;
bool value_unboxed1 = value_boxed; // implicit
bool value_unboxed2 = xtd::unboxing(value_boxed); // explict
auto value_unboxed3 = xtd::unboxing(value_boxed); // explict with auto is bool

See also