Skip to content

Commit

Permalink
Bugfix: Allow to compile with C++17
Browse files Browse the repository at this point in the history
  • Loading branch information
gabyx committed Jan 2, 2020
1 parent b35bcbf commit 06949aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions include/crossguid/guid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ BEGIN_XG_NAMESPACE
class Guid
{
public:
Guid();

explicit Guid(const std::array<unsigned char, 16> &bytes);
explicit Guid(std::array<unsigned char, 16> &&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;
Expand Down
4 changes: 4 additions & 0 deletions src/guid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 06949aa

Please sign in to comment.