Array of pairs does not work in root

Hi,

I can not make the following piece of code to work in root. Can somebody tell me how can I fix it or recommend some other way to do it. I want a function that returns “bool true” when both row and column are matched to the row and column in the list of pairs.

#include <utility>

pair_test() {
inline bool noisy(int col, int row) {
  std::pair <int,int> noisy_pixel_list[] {
    std::pair <int,int>    (15,66),
      std::pair <int,int>     (15,67),
      std::pair <int,int>     (14,66),
      std::pair <int,int>     (14,67),
      std::pair <int,int>     (14,68),
      std::pair <int,int>     (14,69),
      std::pair <int,int>     (18,78),
      std::pair <int,int>     (14,65),
      std::pair <int,int>     (16,66) 
      };
  for(int i=1;i<7;i++) {
    cout << noisy_pixel_list[i].first << " " << noisy_pixel_list[i].second << endl;
    if(col==noisy_pixel_list[i].first && row==noisy_pixel_list[i].second) return true;
    else retrun false;
  }
}
 if( !noisy(1,3)) cout << "good" << endl;
}

Thank you,

Dmitry.

Hi Dmitry,

Array handling in general and initialization of array of object in particular is one of the weak point of CINT. You can either use a vector of pair (or possibly even better an map<int,int>) or you can compile your code (which has several syntax errors (see correctly below)) with ACLiC (.L myscript.C+).

Cheers,
Philippe

[code]#include
#include

inline bool noisy(int col, int row) {
std::pair <int,int> noisy_pixel_list[] = {
std::pair <int,int> (15,66),
std::pair <int,int> (15,67),
std::pair <int,int> (14,66),
std::pair <int,int> (14,67),
std::pair <int,int> (14,68),
std::pair <int,int> (14,69),
std::pair <int,int> (18,78),
std::pair <int,int> (14,65),
std::pair <int,int> (16,66)
};
for(int i=1;i<7;i++) {
cout << noisy_pixel_list[i].first << " " << noisy_pixel_list[i].second << endl;
if(col==noisy_pixel_list[i].first && row==noisy_pixel_list[i].second) return true;
else return false;
}
return false;
}
void pair_test() {
if( !noisy(1,3)) cout << “good” << endl;
}[/code]