summaryrefslogtreecommitdiffstats
path: root/contrib/python/pythran/pythran/pythonic/builtins/str/lstrip.hpp
blob: d3a031bfede84789ae962b6bfdb229fe910e9f00 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef PYTHONIC_BUILTIN_STR_LSTRIP_HPP
#define PYTHONIC_BUILTIN_STR_LSTRIP_HPP

#include "pythonic/include/builtins/str/lstrip.hpp"

#include "pythonic/types/str.hpp"
#include "pythonic/utils/functor.hpp"

PYTHONIC_NS_BEGIN

namespace builtins
{

  namespace str
  {

    types::str lstrip(types::str const &self, types::str const &to_del)
    {
      auto chars = self.chars();
      auto stop = self.find_first_not_of(to_del);
      if (stop < 0)
        return {};
      else
        return {chars.begin() + stop, chars.end()};
    }
  }
}
PYTHONIC_NS_END
#endif