M
mmacrobert
Hi Everyone,
I wrote 2 functions to make a C-Style array play nice with
std::algorithms as shown:
template <typename T>
T begin(T& t)
{
return t;
}
template <typename T>
T end(T& t)
{
return (t + sizeof(t)/sizeof(t[0]));
}
Usage with a std::algorithm was easy. Thus...
const char* c_style_array[] = {"one","two","three"};
std::for_each(
begin(c_style_array),
end(c_style_array),
...do something);
Life was beautiful,
BUT...
Apparently, my compiler was not standards compliant. On moving to a
more compliant compiler my code broke.
How can I re-write my functions to make my code work again? This
non-compliance is pretty prolific through the codebase.
Thanks,
M
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
I wrote 2 functions to make a C-Style array play nice with
std::algorithms as shown:
template <typename T>
T begin(T& t)
{
return t;
}
template <typename T>
T end(T& t)
{
return (t + sizeof(t)/sizeof(t[0]));
}
Usage with a std::algorithm was easy. Thus...
const char* c_style_array[] = {"one","two","three"};
std::for_each(
begin(c_style_array),
end(c_style_array),
...do something);
Life was beautiful,
BUT...
Apparently, my compiler was not standards compliant. On moving to a
more compliant compiler my code broke.
How can I re-write my functions to make my code work again? This
non-compliance is pretty prolific through the codebase.
Thanks,
M
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]