How to generically pass parameters to a function. General C++ question

This is how you would do it with templates:

boolean condition = true;

template <typename T> void my_lcd_print (T arg);
template <typename T> void my_lcd_print (T arg)
  {
  if (condition)
    Serial.println (arg);
  }

void setup ()
  {
  Serial.begin (115200);
  my_lcd_print (42);
  my_lcd_print ("Hi there");
  my_lcd_print (12.34);
  }  // end of setup

void loop () { }

Output:

42
Hi there
12.34

I'm passing three different types there, to a single function. The "template" part makes the compiler generate one function per type.