POV-Ray : Newsgroups : povray.off-topic : c++ template types for function : c++ template types for function Server Time
20 Oct 2021 13:44:17 EDT (-0400)
  c++ template types for function  
From: Bald Eagle
Date: 28 Apr 2020 20:40:00
Message: <web.5ea8ccaba075fdb6fb0b41570@news.povray.org>
So, I'm trying to initialize some arrays, of a size determined by how many
sensors are specified in a little control panel section of the code.

I [finally] wrote a working function ( ZeroArray )

//------------------------------------------------
void ZeroArray (float *Array)
{
 for (int Element = 0; Element < NumSensors; Element++)
 {
  Array [Element] = 0;
 }
}
//------------------------------------------------

and now I'm trying to initialize arrays either with floats OR bool values

//---------------------------------------------------------
template <typename T, typename N>
void InitializeArray (T *Array, N *Value)
{
 for (int Element = 0; Element < NumSensors; Element++)
 {
  Array [Element] = Value;
 }
}
//---------------------------------------------------------

Of course, I have no idea WTH I'm doing and trying to search online for a sane,
concise, and meaningful answer is difficult and time consuming.

void setup ()
{
     ...
     line 224:   InitializeArray (IntegralOutOfRange, false);
     ...
}


/home/oem/Arduino/Sketches/TempSensorCalibratorv0.1.0/TempSensorCalibratorv0.1.0.ino:
In function 'void setup()':
TempSensorCalibratorv0.1.0:224:44: error: no matching function for call to
'InitializeArray(bool [2], bool)'
  InitializeArray (IntegralOutOfRange, false);
                                            ^
/home/oem/Arduino/Sketches/TempSensorCalibratorv0.1.0/TempSensorCalibratorv0.1.0.ino:137:6:
note: candidate: template<class T, class N> void InitializeArray(T*, N*)
 void InitializeArray (T *Array, N *Value)
      ^~~~~~~~~~~~~~~
/home/oem/Arduino/Sketches/TempSensorCalibratorv0.1.0/TempSensorCalibratorv0.1.0.ino:137:6:
note:   template argument deduction/substitution failed:
/home/oem/Arduino/Sketches/TempSensorCalibratorv0.1.0/TempSensorCalibratorv0.1.0.ino:224:44:
note:   mismatched types 'N*' and 'bool'
  InitializeArray (IntegralOutOfRange, false);


Any ideas?


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.