object-introspection icon indicating copy to clipboard operation
object-introspection copied to clipboard

std::variant is not implemented for treebuilder v2

Open JakeHillion opened this issue 2 years ago • 1 comments

This is probably the most difficult type to support, given its template varargs. I would leave this one for me unless you're feeling particularly adventurous.

Examples:

  • OilIntegration.std_variant_char_int64_1
  • OilIntegration.std_variant_char_int64_2
  • OilIntegration.std_variant_vector_int_1
  • OilIntegration.std_variant_vector_int_2
  • OilIntegration.std_variant_optional
  • OilIntegration.std_variant_empty
  • OilIntegration.std_variant_256_params_256
  • OilIntegration.std_variant_256_params_empty

JakeHillion avatar Aug 18 '23 17:08 JakeHillion

This is a bit more problematic than expected. TBv2 generates the handler for std::variant as struct TypeHandler<Ctx, std::variant<T0, T1>> based on the number of arguments the first variant it encounters has. This is in contrast to the usual CodeGen-v2 where the container specification details that the template is template <typename... Types>.

We need some extra container configuration parameter to make this work. Annoyingly we need CodeGen to generate:

template <typename Ctx, typename... Types>
struct TypeHandler<Ctx, std::variant<Types...>> {};

Where the Types pack appears differently in each case. There is some planning required here, though of the current containers this will only apply to std::variant and parameters with parameter packs likely aren't very common.

JakeHillion avatar Jan 09 '24 17:01 JakeHillion