FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
October 01, 2004

Ranges: Concepts and Implementations

(Page 4 of 6)

October, 2004: Ranges: Concepts and Implementations

Listing 2

// Listing 2: ChildWindows_range Indirect Range class
class ChildWindows_range
  : public stlsoft::indirect_range_tag
{
public:
   typedef ChildWindows_range  class_type;
  typedef HWND                value_type;

public:
  ChildWindows_range(HWND hwnd)
    : m_hwnd(hwnd)
  {}
  template <typename F>
  F for_each(F f);
  template <typename T>
  size_t count(T const &val) const;
  template <typename P>
  size_t count_if(P pr) const;
  template <typename O>
  O copy(O o) const;
  ptrdiff_t distance() const
  {
    struct Internal_
    {
      static BOOL CALLBACK distance_Proc(HWND , LPARAM lParam)
      {
        ptrdiff_t &n  = *reinterpret_cast<ptrdiff_t*>(lParam);
        ++n;
        return true;
      }
    };
    ptrdiff_t n = 0;
    ::EnumChildWindows( m_hwnd, Internal_::distance_Proc
                      , reinterpret_cast<LPARAM>(&n));
    return n;
  }
  HWND max_element() const;
  template <typename F>
  HWND max_element(F f) const;
  HWND min_element() const;
  template <typename F>
  HWND min_element(F f) const;
private:
  HWND  m_hwnd;
};

Previous Page | 1 | 2 | 3 | 4 | 5 | 6 Next Page
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK