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
August 01, 2003

Generalized String Manipulation: Access Shims and Type Tunneling

(Page 11 of 20)
Listing 7: Generalization via traits

Listing 7: Generalization via traits

namespace stlsoft
{
  template <typename T>
  struct string_access_traits
  {
    static typename T::value_type const *c_str(T const &s)
    {
      return s.c_str();
    }
    static size_t length(T const &s)
    {
      return s.length();
    }
  };

  template <>
  struct string_access_traits<char const *>
  {
    static char const *c_str(char const *s)
    {
      return s;
    }
    static size_t length(char const *s)
    {
      return strlen(s);
    }
  };
}

Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 Next Page
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK