Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ CXX ?= $(CXXPREFIX)g++$(CXXSUFFIX)
# Check compiler support for some functions
RESULT_HAS_NP_FUNCTIONS := $(shell $(CXX) -o npfunc checks/npfunc.cpp -pthread 2> /dev/null ; echo $$? ; rm -rf npfunc)
RESULT_HAS_ATOMIC_FUNCTIONS := $(shell $(CXX) -o atomic checks/atomic.cpp 2> /dev/null ; echo $$? ; rm -rf atomic)
RESULT_HAS_STRING_VIEW := $(shell $(CXX) -std=c++17 -o string_view checks/string_view.cpp -pthread 2> /dev/null ; echo $$? ; rm -rf string_view)
RESULT_HAS_AUTO_TUPLE := $(shell $(CXX) -std=c++17 -o auto_tuple checks/auto_tuple.cpp -pthread 2> /dev/null ; echo $$? ; rm -rf auto_tuple)

# Enable Backport mode (ancient compilers previous to C++17)
ifeq "$(RESULT_HAS_STRING_VIEW)" "1"
CFLAGS += -isystem nonstd -DNEED_BACKPORT
else ifeq "$(RESULT_HAS_AUTO_TUPLE)" "1"
CFLAGS += -isystem nonstd -DNEED_BACKPORT
endif

# Includes needed for proper compilation
INCLUDES +=
Expand Down
6 changes: 6 additions & 0 deletions checks/auto_tuple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <tuple>
int main(void) {
std::tuple<char, int> foo(0,'h');
auto [c,i] = foo;
return 0;
}
7 changes: 7 additions & 0 deletions checks/string_view.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <string>
#include <string_view>
int main(void) {
std::string foo("hello");
std::string_view sv{foo};
return foo == sv;
}
18 changes: 18 additions & 0 deletions nonstd/string_view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* string_view

Free public domain license

Including string_view_lite from:
https://github.com/martinmoene/string-view-lite
wget https://raw.githubusercontent.com/martinmoene/string-view-lite/master/include/nonstd/string_view.hpp
*/
#ifndef NONSTD__STRING_VIEW_
#define NONSTD__STRING_VIEW_

#include "string_view.hpp"

namespace std {
using string_view = nonstd::string_view;
}

#endif // NONSTD__STRING_VIEW_
Loading