18

How to check if an std::wstring is null or empty?

bluish
  • 26,356
  • 27
  • 122
  • 180
subs
  • 2,189
  • 12
  • 35
  • 59

1 Answers1

33

wstring is not a pointer, it cannot be null. You can check if it's empty (that is, is equivalent to "") either by direct comparison to the previous, or by:

str.empty(); // == (str.size() == 0)
GManNickG
  • 494,350
  • 52
  • 494
  • 543