Skip to content

Commit

Permalink
Add detection of stod for std::stringview
Browse files Browse the repository at this point in the history
  • Loading branch information
pcanal committed Feb 24, 2016
1 parent 2599f3b commit 75d3b58
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
16 changes: 16 additions & 0 deletions cmake/modules/RootConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,22 @@ else()
set(hasstdexpstringview undef)
endif()

if(found_stdstringview)
CHECK_CXX_SOURCE_COMPILES("#include <string_view>
int main() { size_t pos; std::string_view str; std::stod(str,&pos); return 0;}" found_stod_stringview)
elseif(found_stdexpstringview)
CHECK_CXX_SOURCE_COMPILES("#include <experimental/string_view>
int main() { size_t pos; std::experimental::string_view str; std::stod(str,&pos); return 0;}" found_stod_stringview)
else()
set(found_stod_stringview false)
endif()

if(found_stod_stringview)
set(hasstodstringview define)
else()
set(hasstodstringview undef)
endif()

#---root-config----------------------------------------------------------------------------------------------
ROOT_SHOW_OPTIONS(features)
string(REPLACE "c++11" "cxx11" features ${features}) # change the name of the c++11 feature needed for root-config.in
Expand Down
1 change: 1 addition & 0 deletions config/RConfigure.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#@uselibc++@ R__USE_LIBCXX /**/
#@hasstdstringview@ R__HAS_STD_STRING_VIEW /**/
#@hasstdexpstringview@ R__HAS_STD_EXPERIMENTAL_STRING_VIEW /**/
#@hasstodstringview@ R__HAS_STOD_STRING_VIEW /**/
#@hasllvm@ R__EXTERN_LLVMDIR @llvmdir@
#@useimt@ R__USE_IMT /**/

Expand Down
16 changes: 14 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2775,19 +2775,30 @@ fi

hasstdstringview="undef"
hasstdexpstringview="undef"
hasstodstringview="undef"
message "Checking for string_view implementation"
if test "x$usecxx11" = "xdefine" ; then
check_code '#include <string_view>
int main() {std::string_view().to_string(); return 0; }'
int main() {std::string_view().to_string(); return 0; }' '$(CXX11FLAGS)'
if test $include_result -eq 1 ; then
hasstdstringview="define"
result '<string_view>'
check_code '#include <string_view>
int main() { size_t pos; std::string_view str; std::stod(str,&pos); return 0;}' '$(CXX11FLAGS)'
if test $include_result -eq 1 ; then
hasstodstringview="define"
fi
else
check_code '#include <experimental/string_view>
int main() {std::experimental::string_view().to_string(); return 0; }'
int main() {std::experimental::string_view().to_string(); return 0; }' '$(CXX11FLAGS)'
if test $include_result -eq 1 ; then
hasstdexpstringview="define"
result '<experimental/string_view>'
check_code '#include <experimental/string_view>
int main() { size_t pos; std::experimental::string_view str; std::stod(str,&pos); return 0;}' '$(CXX11FLAGS)'
if test $include_result -eq 1 ; then
hasstodstringview="define"
fi
else
result "using builtin string_view"
fi
Expand Down Expand Up @@ -7952,6 +7963,7 @@ sed \
-e "s|@uselibc++@|$uselibcxx|" \
-e "s|@hasstdstringview@|$hasstdstringview|" \
-e "s|@hasstdexpstringview@|$hasstdexpstringview|" \
-e "s|@hasstodstringview@|$hasstodstringview|" \
-e "s|@hasllvm@|$hasllvm|" \
-e "s|@llvmdir@|$llvmdir|" \
-e "s|@useimt@|$useimt|" \
Expand Down

0 comments on commit 75d3b58

Please sign in to comment.