User:Mikero

My name is Michael Goldshteyn. I have been on the #c++ channel, under the nandle mikero, since the early nineties and have been an op for well over a decade. I have been programming, daily, since I was about 13 years old, back in 1983. My first programming language was BASIC, from which I slowly transitioned to C in 1985. Around 1989, I discovered C++ and have been actively programming in it, since. My favorite scripting language is Perl, which I have been using since the late nineties. The choice of Perl was primarily due to the ease with which one can solve a scripting problem by utilizing a module or modules from CPAN.

I am currently employed in the financial sector, doing Windows C++ development. My interests include programming, photography, and watching as much TV as family life allows me. I am married and have two sons, Joshua (5 y.o.) and Benjamin (2 y.o.).

Here is my obligatory "Hello, world" code:

Potential C++ Standard contributions Here are some algorithms I was hoping would make their way into the next revision of the C++ Standard (See section 4.3 of: 14 crazy ideas for the standard library in C++0x), along with implementations written by me:

is_sorted  template  bool is_sorted(ForwardIterator first, ForwardIterator last) { if (first!=last) for (ForwardIterator it(first++);first!=last;++it /* or it=first */,++first) if (*first<*it) return false;

return true; }

template  bool is_sorted(ForwardIterator first, ForwardIterator last,              Predicate pred) { if (first!=last) for (ForwardIterator it(first++);first!=last;++it /* or it=first */,++first) if (!pred(*it,*first)) return false;

return true; }

nonunique_copy  template OutputIterator nonunique_copy(InputIterator first1, InputIterator last1, OutputIterator first2) { if (first1!=last1) // Test for empty range for (InputIterator prev(first1++);first1!=last1;++prev,++first1) if (*first1==*prev) // Test if current pair is not unique {       *first2++=*first1; // Store in output sequence for // Find next set of distinct elements {         prev=first1++; if (first1==last1) // End of input range hit, done return first2; if (!(*first1==*prev)) // Next non-unique pair found, skip and look for next dupe break; }       }

return first2; }

template OutputIterator nonunique_copy(InputIterator first1, InputIterator last1, OutputIterator first2, BinaryPredicate pred) { if (first1!=last1) // Test for empty range for (InputIterator prev(first1++);first1!=last1;++prev,++first1) if (pred(*first1,*prev)) // Test if current pair is not unique {       *first2++=*first1; // Store in output sequence for // Find next set of distinct elements {         prev=first1++; if (first1==last1) // End of input range hit, done return first2; if (!pred(*first1,*prev)) // Next non-unique pair found, skip and look for next dupe break; }       }

return first2; }

Sample code highlighting usage of nonunique_copy

Other useful class templates select1st and select2nd - some useful class templates for pair element isolation</H2> <pre style="margin: 0px; padding: 4px; border: none; background: #fcfcff">
 * 1) include

template <typename pair_type> struct select1st: public std::unary_function<const pair_type &, typename const pair_type::first_type &> { const typename pair_type::first_type &operator(const pair_type &v) const {   return v.first; } };

template <typename pair_type> struct select2nd: public std::unary_function<const pair_type &, typename const pair_type::second_type &> { const typename pair_type::second_type &operator(const pair_type &v) const {   return v.second; } };

Sample code highlighting usage of select1st and select2nd</H5>

Sample code converted to use boost::bind instead of select1st and select2nd</H5>