Skip to main content
added 62 characters in body
Source Link
user142019
user142019

There is a difference between null and empty string (an empty string is still a valid string). If you want a "nullable" object (something that can hold at most one object of a certain type), you can use boost::optional:

boost::optional<std::string> str; // str is *nothing* (i.e. nullthere is no string) str = "Hello, world!"; // str is "Hello, world!" str = ""; // str is "" (i.e. empty string) 

There is a difference between null and empty string (an empty string is still a valid string). If you want a "nullable" object (something that can hold at most one object of a certain type), you can use boost::optional:

boost::optional<std::string> str; // str is *nothing* (i.e. null) str = "Hello, world!"; // str is "Hello, world!" 

There is a difference between null and empty string (an empty string is still a valid string). If you want a "nullable" object (something that can hold at most one object of a certain type), you can use boost::optional:

boost::optional<std::string> str; // str is *nothing* (i.e. there is no string) str = "Hello, world!"; // str is "Hello, world!" str = ""; // str is "" (i.e. empty string) 
added 65 characters in body
Source Link
user142019
user142019

There is a difference between null and empty string (an empty string is still a valid string). If you want a "nullable" object (something that can hold at most one object of a certain type), you can use boost::optional:

boost::optional<std::string> str; // str is *nothing* (i.e. null) str = "Hello, world!"; // str is "Hello, world!" 

There is a difference between null and empty string (an empty string is still a valid string). If you want a "nullable" object, you can use boost::optional:

boost::optional<std::string> str; // str is *nothing* (i.e. null) str = "Hello, world!"; // str is "Hello, world!" 

There is a difference between null and empty string (an empty string is still a valid string). If you want a "nullable" object (something that can hold at most one object of a certain type), you can use boost::optional:

boost::optional<std::string> str; // str is *nothing* (i.e. null) str = "Hello, world!"; // str is "Hello, world!" 
Source Link
user142019
user142019

There is a difference between null and empty string (an empty string is still a valid string). If you want a "nullable" object, you can use boost::optional:

boost::optional<std::string> str; // str is *nothing* (i.e. null) str = "Hello, world!"; // str is "Hello, world!"