"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:gr2bjd$st4$1@news.datemas.de...
Hicham Mouline wrote:
namespace NS1 { namespace NS2 {
template <typename T1, typename T2>
class C {
public:
typedef T1::xType xType;
typedef T1::yType yType;
...
private:
typedef std::pair< xType, yType> EntryType;
boost::array< EntryType , size > ContainerType;
....
};
...
}}
I need to use std::lower_bound and sorting algorithms on my
ContainerType.
Where (which namespace) and how can I define the operator< comparing 2
EntryType
for the std:: algorithms to use that operator?
Anywhere appropriate. Any namespace/class where your compiler is
capable of finding it.
Note I use these std::algorithms only in member functions of the C
template.
So I wish to define the operator< in a way that is specific and visible
only to C template.
Have you tried defining it as a static member of the C template?
Post the rest of your code, with only the operator< missing, and we can
probably figure it out. I am just too lazy to provide all the necessary
driver code for what you've described, I consider it your job if you
want my help. Sorry, such a PITA I am.
V
Not at all. Thank you for your contrib!
I put the code here
http://codepad.org/Gwfm36GL
It fails to compile under g++4
"operator< needs to be must be either a non-static member function or a
non-member function"
if it is member non-static, it is interpreted as applying to C<T1,T2> not
to EntryType
As EntryType is private, I don't know how to define outside of C<T1,T2>