diff --git a/README.md b/README.md index 44c6164..ea70159 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,9 @@ cmake .. make install ``` +The library can also be build with `c++17` by using `-DCMAKE_CXX_STANDARD=17` +which enables `std::string_view` support. + ## Running tests After compiling as described above you should get two files: `libcrossguid.a` (the diff --git a/include/crossguid/guid.hpp b/include/crossguid/guid.hpp index 61e0f17..d15b021 100644 --- a/include/crossguid/guid.hpp +++ b/include/crossguid/guid.hpp @@ -49,12 +49,17 @@ BEGIN_XG_NAMESPACE class Guid { public: + Guid(); + explicit Guid(const std::array &bytes); explicit Guid(std::array &&bytes); +#if __cplusplus >= 201703L explicit Guid(std::string_view fromString); - Guid(); - +#else + explicit Guid(std::string fromString); +#endif + Guid(const Guid &other) = default; Guid &operator=(const Guid &other) = default; Guid(Guid &&other) = default; diff --git a/src/guid.cpp b/src/guid.cpp index 3061a9b..57df2e5 100644 --- a/src/guid.cpp +++ b/src/guid.cpp @@ -198,7 +198,11 @@ unsigned char hexPairToChar(char a, char b) } // create a guid from string +#if __cplusplus >= 201703L Guid::Guid(std::string_view fromString) +#else +Guid::Guid(std::string fromString) +#endif { char charOne = '\0'; char charTwo = '\0';