.. _types_overview: Overview ================ Rice enable native C++ code and Ruby code to work together. This requires translating types between the two languages. C++ Types ----------------- C++ defines `fundamental `_ and `compound `_ types. Fundamental types consist of void, integers, float, double, etc. Compound types are everything else such as enums, arrays, classes, pointers, references, etc. .. _type_mapping: Type Mapping ------------ Objects can either be converted or wrapped. Converted objects are copied between the two languages. For example, a C++ integer is copied to a Ruby Integer resulting in two disconnected objects. If you update the value of the Ruby integer the change is *not* reflected in the C++ integer. For more information refer to the :doc:`Type Conversion ` section. Wrapped objects are C++ objects that are wrapped by Ruby objects, or alternatively, Ruby objects wrapped by C++ objects. Thus the two objects are connected. For example, if a C++ object is wrapped by a Ruby object then any modifications to the Ruby object will be reflected in the C++ object. For more information refer to the :doc:`Type Wrapping ` section. The table below shows how fundamental and compound C++ types are mapped to Ruby types based on whether they are passed by value, reference or pointer. ====================== ================ ============ C++ Type Fundamental Compound ====================== ================ ============ Value (T) Converted Wrapped Reference (T&) Converted Wrapped Pointer (T*) Pointer Wrapped Array (T[]) Pointer Pointer Pointer (T**) Pointer Pointer ====================== ================ ============ The :doc:`Pointer <../bindings/pointers>` classes are automatically generated by Rice to wrap C++ arrays and pointers to fundamental types. Use :doc:`Buffers <../bindings/buffers>` to manipulate the pointer's memory.