Turi Create  4.0
turi::variant_converter< T, Enable > Struct Template Reference

#include <model_server/lib/variant_converter.hpp>

Detailed Description

template<typename T, class Enable = void>
struct turi::variant_converter< T, Enable >

The variant_converter<T> is a class which exposes two member functions.

T variant_converter<T>::get(const variant_type&)
variant_type variant_converter<T>::set(const T&)

Essentially variant_converter::get converts from a variant type to an arbitrary type T, and variant_converter::set converts from an arbitrary type T to a variant_type.

The key is to support as interesting types for T as possible. The following are currently supported:

  • variant_type
  • any direct member of variant_type:
    • std::shared_ptr<unity_sarray_base>
    • std::shared_ptr<unity_sframe_base>
    • std::shared_ptr<unity_sgraph_base>
    • std::shared_ptr<model_base>
    • std::vector<variant_type>
    • std::map<std::string, variant_type>
  • everything convertible to flexible_type (See flexible_type_conveter.hpp)
  • std::shared_ptr<unity_sarray>
  • std::shared_ptr<unity_sframe>
  • std::shared_ptr<unity_sgraph>
  • gl_sarray
  • gl_sframe
  • gl_sgraph
  • gl_gframe
  • std::shared_ptr<T> where T is a descendent of model_base
  • variant_type
  • Recursive cases
    • std::vector<T> where T is of any type in this list including the recursive cases.
    • std::map<std::string, T> where T is of any type in this list including the recursive cases.
    • std::unordered_map<std::string, T> where T are of any type in this list including the recurrsive cases.
    • std::pair<S, T> where S, T are of any type in this list including the recursive cases.
    • std::tuple<T...> where T... are of any type in this list including the recursive cases.

variant_converter_implementation Details

The key difficulty is to make sure that every T matches exactly one case. Each case below is numbered, and we document here how each situation maps to each case.

Base case. All failed templatizations will come here where compilation will fail.

Definition at line 151 of file variant_converter.hpp.


The documentation for this struct was generated from the following file: