STL set container in ROOT (sample code corrected)

From: Vassili Maroussov <Vassili.Maroussov_at_cern.ch>
Date: Thu, 31 Jul 2008 11:52:06 +0200


Dear ROOTers,

I'm wondering why the STL "set" works differently in a ROOT session and compiled code. More specifically, why in the ROOT session it requires an explicit declaration of "Compare" while the comparison for object is defined. For instance consider the following sample code:

*///file: test_set.C/

#include <iostream>
#include <set>

void test_set()
{

   int *i1 = new int();
   int *i2 = new int();

   ///Checking whether the integer pointer comparison is defined/    std::cout << "(i1 < i2) = " << (i1 < i2) << "\t"

             << "(i1 > i2) = " << (i1 > i2) << std::endl;

   ///Declaring a set of integer pointers/    set<int*> ip_set;
} ///end file test_set.C/
*

The ROOT session transcript:

*root [0] .x test_set.C

(i1 < i2) = 1 (i1 > i2) = 0

Error: Too few template arguments test_set.C:14:
Error: template argument for Compare missing test_set.C:43:
Error: template argument for Compare missing test_set.C:44:
Error: template argument for Compare missing test_set.C:62:
Error: template argument for Compare missing test_set.C:62:
Error: template argument for Compare missing test_set.C:64:
Error: template argument for Compare missing test_set.C:64:

*

I'm also wondering how line numbers 43-64 can appear in the error massages, the sample code is just 15 lines long?

Regards,

Vassili Received on Thu Jul 31 2008 - 11:52:10 CEST

This archive was generated by hypermail 2.2.0 : Thu Jul 31 2008 - 17:50:02 CEST