lidavidm commented on a change in pull request #12717:
URL: https://github.com/apache/arrow/pull/12717#discussion_r836664537



##########
File path: docs/source/cpp/api/utilities.rst
##########
@@ -56,3 +56,132 @@ Compression
 
 .. doxygenclass:: arrow::util::Decompressor
    :members:
+
+Visitors
+========
+
+.. doxygenfunction:: arrow::VisitTypeInline
+   :project: arrow_cpp
+
+.. doxygenfunction:: arrow::VisitTypeIdInline
+   :project: arrow_cpp
+
+.. doxygenfunction:: arrow::VisitScalarInline
+   :project: arrow_cpp
+
+.. doxygenfunction:: arrow::VisitArrayInline
+   :project: arrow_cpp
+
+
+.. _type-traits:
+
+Type Traits
+===========
+
+These types provide relationships between Arrow types at compile time. 
:cpp:type:`TypeTraits`
+maps Arrow DataTypes to other types, and :cpp:type:`CTypeTraits ` maps C types 
to
+Arrow types.
+
+TypeTraits
+----------
+
+Each specialized type defines the following associated types:
+
+.. cpp:type:: TypeTraits::ArrayType
+
+  Corresponding :doc:`Arrow array type </cpp/api/array.rst>`
+
+.. cpp:type:: TypeTraits::BuilderType
+
+  Corresponding :doc:`array builder type </cpp/api/builders.rst>`
+
+.. cpp:type:: TypeTraits::ScalarType
+
+  Corresponding :doc:`Arrow scalar type </cpp/api/scalar.rst>`
+
+.. cpp:var:: TypeTraits::is_parameter_free
+
+  Whether the type has any type parameters, such as field types in nested types
+  or scale and precision in decimal types.
+
+
+In addition, the following are defined for many but not all of the types:
+
+.. cpp:type:: TypeTraits::CType
+
+  Corresponding C type. For example, ``int64_t`` for ``Int64Array``.
+
+.. cpp:type:: TypeTraits::TensorType
+
+  Corresponding :doc:`Arrow tensor type </cpp/api/tensor.rst>`
+
+.. cpp:function:: static inline constexpr int64_t bytes_required(int64_t 
elements)
+
+  Return the number of bytes required for given number of elements. Defined 
for 
+  types with a fixed size.
+
+.. cpp:function:: static inline std::shared_ptr<DataType> 
TypeTraits::type_singleton()
+
+  For types where is_parameter_free is true, returns an instance of the data 
type.
+
+
+.. doxygengroup:: type-traits
+   :content-only:
+   :members:
+   :undoc-members:
+
+CTypeTraits
+-----------
+
+Each specialized type defines the following associated types:
+
+.. cpp:type:: CTypeTraits::ArrowType
+
+  Corresponding :doc:`Arrow type </cpp/api/datatype.rst>`
+
+.. doxygengroup:: c-type-traits
+   :content-only:
+   :members:
+   :undoc-members:
+
+
+.. _type-predicates-api:
+
+Type Predicates
+---------------
+
+Type predicates that can be used with templates. Predicates of the form 
``is_XXX`` 
+resolve to constant boolean values, while predicates of the form 
``enable_if_XXX`` 
+resolve to the second type parameter ``R`` if the first parameter ``T`` passes 
+the test.
+
+Example usage:
+
+.. code-block:: cpp
+
+  template<typename TypeClass>
+  arrow::enable_if_number<TypeClass, RETURN_TYPE> my_function(const TypeClass& 
type) {

Review comment:
       nit here and below as well, try to follow the Arrow convention?

##########
File path: docs/source/cpp/datatypes.rst
##########
@@ -66,3 +66,139 @@ To instantiate data types, it is recommended to call the 
provided
    type = arrow::timestamp(arrow::TimeUnit::MICRO);
    // A list type of single-precision floating-point values
    type = arrow::list(arrow::float32());
+
+
+
+Type Traits
+-----------
+
+Writing code that can handle concrete :class:`arrow::DataType` subclasses 
would 
+be verbose, if it weren't for type traits. Similar to the type traits provided
+in `std::type_traits <https://en.cppreference.com/w/cpp/header/type_traits>`_,
+Arrow's type traits map the Arrow data types to the specialized array, scalar, 
+builder, and other associated types. For example, the Boolean type has traits:

Review comment:
       Just to be precise, they are similar in _concept_ (the C++ utilities 
look quite different after all) but for both the main goal is to make 
metaprogramming easier. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to