Ŀ
 type_info.cpp 


#include <stdio.h>
#include <stdlib.h>
#include <functional>
#include <typeinfo>

#define WR /*WR*/
#define RC /*RC*/

#define export using /*namespaces*/
#define transitive /*export-not-required*/

#define include if constexpr /*legacy*/
#define var auto /*new-heap-var*/

#define with std::function
typedef void struct_ptr;
#define self_ptr this

#define size_of(x) ( sizeof (x) )
#define array_size(x) ( sizeof (x) )
#define array_length(x) ( sizeof (x) / sizeof (x[0]) )

#define free(ptr) ( delete *ptr, *ptr = NULL )

#define t_id(x) ( typeid (x).hash_code () )
#define t_name(x) ( typeid (x).name () )

typedef unsigned char byte;
typedef unsigned long ulong;

/* * */

namespace colors
{
  struct WR Color
  {
    byte _,
         red, 
         green, 
         blue = 0;

    Color (with <void (Color WR *)> init = NULL)
    {
      if (init) init (self_ptr);
    }

    byte is_empty () 
    {
      return (!red && !green && !blue) ? 1 : 0;
    }
  };
}

export colors::Color;

/* * */

int main ()
{
  Color red ([=] (var WR *p) { 
                               p->red = 255;
                             });

  var *black = new Color {0};

  printf ("%d" "\t" "%s" "\n", t_id (red),    t_name (red));
  printf ("%d" "\t" "%s" "\n", t_id (&red),   t_name (&red));
  printf ("%d" "\t" "%s" "\n", t_id (*black), t_name (*black));
  printf ("%d" "\t" "%s" "\n", t_id (black),  t_name (black));

  printf ("%d" "\n", red.is_empty ());
  printf ("%d" "\n", black->is_empty ());

  free (&black);

  return 0;
}