T
towi
Hello,
I noticed that C++0x will allow the following:
void func() {
struct Op { // locally defined type
void operator()(int arg) { /*...*/ }
};
std::for_each(..., Op()); // using Op as template argument
}
where before it was prohibited to use "Op" there because it is a
template argument there.
I wonder... why was this not included in C++98? What is/was the main
challange in allowing this for compiler implementors?
I have the feeling it has something to do with scopes an visibility of
variables. Something like that in C (and C++98) averything a Functor/
Function can operate on is visible at a global scope. Allowing this
would introduce a complex scenario of making things visible, to where
a Functor is called, what was initially only visible locally where the
Functor is defined. I am aware that this is a challange in Pascal and
a very distinguishing feature of Pascal versus C (and C++98).
Is this correct, or are there other challanges to overcome -- or
reasons why this was not included in C++98.
Thanks in advance,
tschau, towi.
I noticed that C++0x will allow the following:
void func() {
struct Op { // locally defined type
void operator()(int arg) { /*...*/ }
};
std::for_each(..., Op()); // using Op as template argument
}
where before it was prohibited to use "Op" there because it is a
template argument there.
I wonder... why was this not included in C++98? What is/was the main
challange in allowing this for compiler implementors?
I have the feeling it has something to do with scopes an visibility of
variables. Something like that in C (and C++98) averything a Functor/
Function can operate on is visible at a global scope. Allowing this
would introduce a complex scenario of making things visible, to where
a Functor is called, what was initially only visible locally where the
Functor is defined. I am aware that this is a challange in Pascal and
a very distinguishing feature of Pascal versus C (and C++98).
Is this correct, or are there other challanges to overcome -- or
reasons why this was not included in C++98.
Thanks in advance,
tschau, towi.