diff --git a/.Rbuildignore b/.Rbuildignore index 9d65823..fe41dc1 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,4 +3,5 @@ .dir-locals.el .projectile compile_commands.json -.cquery \ No newline at end of file +.cquery +.ccls \ No newline at end of file diff --git a/.dir-locals.el b/.dir-locals.el deleted file mode 100644 index a74d40a..0000000 --- a/.dir-locals.el +++ /dev/null @@ -1 +0,0 @@ -((nil . ((projectile-project-compilation-cmd . "~/bin/compR.sh .")))) diff --git a/.gitignore b/.gitignore index 17b7fc5..77a9d60 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ GPATH GTAGS .cquery* GRTAGS +/src/Makevars +/.lintr +*.idx +/compile_commands.json diff --git a/DESCRIPTION b/DESCRIPTION index 515b60e..1e1d3e2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,18 +1,18 @@ Package: EigenH5 Type: Package Title: Read and write R objects using HDF5 -Version: 1.2 +Version: 1.3 Date: 2017-08-03 Author: Nicholas Knoblauch Maintainer: Nicholas Knoblauch Description: Read and write R objects using zstd+HDF5. Also contains a C++ interface for using with other packages. The C++ interface can handle the reading/writing/converting between column-major matrices (as in R/fortran) and row-major matrices (as in HDF5) License: What license is it under? biocViews: -Imports: Rcpp (>= 0.12.12), RcppEigen (>= 0.3.3.3.0),BH,dplyr,progress,tidyr,purrr,magrittr,zstdr,R6,fs,zstdr -LinkingTo: Rcpp, RcppEigen,RcppProgress,testthat,Rhdf5lib,rzstdlib,BH -SystemRequirements: C++11, HDF5 (>= 1.8.13), blosc +Imports: Rcpp (>= 0.12.12), RcppEigen (>= 0.3.3.3.0),BH,dplyr,progress,tidyr,stringr,purrr,magrittr,fs,readr,rlang +LinkingTo: Rcpp, RcppEigen,RcppProgress,testthat,BH,xtensor +SystemRequirements: C++17,libhdf5,libzstd Suggests: testthat, knitr, rmarkdown VignetteBuilder: knitr -RoxygenNote: 6.1.1 +RoxygenNote: 6.1.99.9001 diff --git a/NAMESPACE b/NAMESPACE index a649115..8ff7f47 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,4 +2,5 @@ useDynLib(EigenH5,.registration=TRUE) importFrom(Rcpp, evalCpp) exportPattern("^[[:alpha:]]+") importFrom(magrittr,"%>%") +importFrom(rlang,"%||%") importFrom(rlang,"!!") diff --git a/R/RcppExports.R b/R/RcppExports.R index 88d5bd2..1d2d722 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -33,6 +33,26 @@ get_group <- function(f, object_name) { .Call(`_EigenH5_get_group`, f, object_name) } +read_matrix_rl <- function(filename, datapath, rows, cols) { + .Call(`_EigenH5_read_matrix_rl`, filename, datapath, rows, cols) +} + +read_matrix_v <- function(filename, datapath, rows, cols) { + .Call(`_EigenH5_read_matrix_v`, filename, datapath, rows, cols) +} + +read_vector_v <- function(filename, datapath, rows) { + .Call(`_EigenH5_read_vector_v`, filename, datapath, rows) +} + +update_matrix_v <- function(data, filename, datapath, rows, cols) { + invisible(.Call(`_EigenH5_update_matrix_v`, data, filename, datapath, rows, cols)) +} + +update_vector_v <- function(data, filename, datapath, rows) { + invisible(.Call(`_EigenH5_update_vector_v`, data, filename, datapath, rows)) +} + openFileHandleRead <- function(filepath) { .Call(`_EigenH5_openFileHandleRead`, filepath) } @@ -41,6 +61,14 @@ closeFileHandle <- function(fh) { .Call(`_EigenH5_closeFileHandle`, fh) } +has_blosc <- function() { + .Call(`_EigenH5_has_blosc`) +} + +has_lzf <- function() { + .Call(`_EigenH5_has_lzf`) +} + start_blosc <- function() { invisible(.Call(`_EigenH5_start_blosc`)) } @@ -77,6 +105,10 @@ write_attribute_h5 <- function(data, filename, datapath) { .Call(`_EigenH5_write_attribute_h5`, data, filename, datapath) } +read_R_attribute_h5 <- function(filename, datapath) { + .Call(`_EigenH5_read_R_attribute_h5`, filename, datapath) +} + read_attribute_h5 <- function(filename, datapath) { .Call(`_EigenH5_read_attribute_h5`, filename, datapath) } @@ -85,6 +117,14 @@ create_dataset_h5 <- function(filename, datapath, data, options) { .Call(`_EigenH5_create_dataset_h5`, filename, datapath, data, options) } +fast_str2int <- function(input, offset = 0L, na_val = NA_integer_) { + .Call(`_EigenH5_fast_str2int`, input, offset, na_val) +} + +fast_str2ascii <- function(input, offset = 0L) { + .Call(`_EigenH5_fast_str2ascii`, input, offset) +} + link_objects_h5 <- function(filename_from, filename_to, datapath_from, datapath_to) { invisible(.Call(`_EigenH5_link_objects_h5`, filename_from, filename_to, datapath_from, datapath_to)) } @@ -121,6 +161,10 @@ isObject <- function(filename, dataname) { .Call(`_EigenH5_isObject`, filename, dataname) } +ArrayTypeSize <- function(filename, dataname) { + .Call(`_EigenH5_ArrayTypeSize`, filename, dataname) +} + isDataSet <- function(filename, dataname) { .Call(`_EigenH5_isDataSet`, filename, dataname) } @@ -137,6 +181,10 @@ typeof_h5 <- function(filename, datapath) { .Call(`_EigenH5_typeof_h5`, filename, datapath) } +info_h5 <- function(filename, datapaths) { + .Call(`_EigenH5_info_h5`, filename, datapaths) +} + file_acc_ct <- function(filename) { .Call(`_EigenH5_file_acc_ct`, filename) } diff --git a/R/chunk_reader_writer.R b/R/chunk_reader_writer.R new file mode 100644 index 0000000..db0e0eb --- /dev/null +++ b/R/chunk_reader_writer.R @@ -0,0 +1,71 @@ +read_matrix_h5v <- function(filename, datapath,i, j, ...){ + has.i <- !missing(i) + has.j <- !missing(j) + if (!has.j){ + j <- integer() + } + if (!has.i){ + i <- integer() + } + argl <- list(...) + stopifnot(length(argl) == 0) + + return(read_matrix_v(filename, datapath, i, j)) + +} + + +read_vector_h5v <- function(filename, datapath, i, ...){ + has.i <- !missing(i) + + if (!has.i){ + i <- integer() + } + argl <- list(...) + stopifnot(length(argl) == 0) + + return(read_vector_v(filename, datapath, i)) + +} + + + + +write_matrix_h5v <- function(data, filename, datapath, ...){ + + argl <- list(...) + filename <- fs::path_expand(filename) + if(!file.exists(filename)){ + # argl[["dim"]] <- argl[["dim"]] %||% dim(data) + create_dataset_h5(filename,datapath,data,argl) + } + if(!isObject(filename,datapath)){ + create_dataset_h5(filename = filename ,datapath = datapath, data = data, options = argl) + } + i <- argl[["i"]] %||% 1:NROW(data) + j <- argl[["j"]] %||% 1:NCOL(data) + update_matrix_v(data,filename = filename,datapath,i,j) +} + + + +write_vector_h5v <- function(data, filename, datapath, ...){ + + argl <- list(...) + filename <- fs::path_expand(filename) + if(!file.exists(filename)){ + # argl[["dim"]] <- argl[["dim"]] %||% dim(data) + create_dataset_h5(filename,datapath,data,argl) + } + if(!isObject(filename,datapath)){ + create_dataset_h5(filename = filename ,datapath = datapath, data = data, options = argl) + } + i <- argl[["i"]] %||% 1:NROW(data) + #j <- argl[["j"]] %||% 1:ncol(data) + update_vector_v(data,filename = filename,datapath,i) +} + + + + + diff --git a/R/read_write.R b/R/read_write.R index c23bb9e..f9cc2c5 100644 --- a/R/read_write.R +++ b/R/read_write.R @@ -1,29 +1,32 @@ -read_df_h5 <- function(filename,datapath,...){ +read_df_h5 <- function(filename, datapath = "/", ...){ filename <- fs::path_expand(filename) - stopifnot(file.exists(filename)) - dsets <- ls_h5(filename,groupname = datapath) - argl <- list(...) - if(!hasArg(subcols)){ - argl[["subcols"]] <- dsets - # subcols <- dsets - } - dsets <- dsets[dsets %in% argl[["subcols"]]] - if(datapath=="/"){ - groupname <- "" - } - dsp <- normalizePath(paste(datapath,dsets,sep="/"), mustWork = F) - names(dsp) <- basename(dsp) - return(purrr::map_dfc(dsp,~read_vector_h5(filename, datapath = .x, ...), ...=...)) + stopifnot(file.exists(filename)) + dsets <- ls_h5(filename, groupname = datapath) + argl <- list(...) + if(!hasArg(subcols)){ + argl[["subcols"]] <- dsets + # subcols <- dsets + } + dsets <- dsets[dsets %in% argl[["subcols"]]] + dsp <- fix_paths(datapath, dsets) + names(dsp) <- basename(dsp) + if(!hasArg(subset)){ + return(purrr::map_dfc(dsp,~read_vector_h5v(filename = filename,datapath = .x))) + }else{ + return(purrr::map_dfc(dsp,~read_vector_h5v(filename = filename,datapath = .x,i=as.integer(argl[["subset"]])))) + } } write_df_h5 <- function(df, filename, datapath="/", ...){ argl <- list(...) - filename <- fs::path_expand(filename) + if(datapath=="/"){ + datapath <- "" + } purrr::iwalk(df, ~purrr::invoke(write_vector_h5, filename = filename, - datapath = normalizePath(paste(datapath, .y, sep="/"),mustWork = F), + datapath = fix_paths(datapath, .y), data=.x, argl)) } @@ -57,16 +60,20 @@ write_vector_h5 <- function(data, filename, datapath, ...){ app_v <- TRUE filename <- fs::path_expand(filename) if(!file.exists(filename)){ + if(isTRUE(argl[["append"]]) && is.null(argl[["max_dims"]])){ + argl[["max_dims"]] <- NA_integer_ + } create_dataset_h5(filename, datapath, data, argl) app_v <- FALSE } if(!isObject(filename, datapath)){ + if(isTRUE(argl[["append"]]) && is.null(argl[["max_dims"]])){ + argl[["max_dims"]] <- NA_integer_ + } create_dataset_h5(filename, datapath, data, argl) }else{ - if(hasArg(append)){ - if(app_v & argl[["append"]]){ - ret <- append_vector_h5(data = data,filename = filename, datapath = datapath, ... = argl) - } + if(app_v && isTRUE(argl[["append"]])){ + ret <- append_vector_h5(data = data,filename = filename, datapath = datapath, ... = argl) } } if(!ret){ diff --git a/R/utils.R b/R/utils.R index d4f6f03..1f578c4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,13 +1,68 @@ -.onLoad <- function(libname, pkgname){ +.onLoad <- function(libname, pkgname) { + pkgconfig::set_config("EigenH5::use_blosc" = has_blosc()) + pkgconfig::set_config("EigenH5::use_lzf" = has_lzf()) start_blosc() - # start_singleton() + +} + +fix_paths <- function(...) { + ret <- stringr::str_replace(normalizePath(paste(..., sep = "/"), mustWork = FALSE), "//", "/") + if (length(ret) == 0) { + ret <- "/" + } + return(ret) } -ls_h5 <- function(filename,groupname="/",full_names=FALSE){ + + +#' Convert RLE-encoded vector to offset+size dataframe +#' +#' @param x either a vector of class `rle`, or a vector that can be converte to one via (`rle(x)`) +#' @param na_replace value to replace NA (rle doesn't play well with NA) +#' +#' @return tibble with columns `value`,`offset` and `datasize` +#' @export +#' +#' @examples +#' x <- rev(rep(6:10, 1:5)) +#' x_na <- c(NA,NA,NA,rev(rep(6:10, 1:5))) +#' x_n3 <- c(-3,-3,-3,rev(rep(6:10, 1:5))) +#' print(rle2offset(rle(x))) +#' stopifnot( +#' identical(rle2offset(rle(x)),rle2offset(x)), +#' identical(rle2offset(x_na,na_replace=-3),rle2offset(x_n3))) +rle2offset <- function(x,na_replace = -1L){ + if (!inherits(x,"rle")){ + x[is.na(x)] <- na_replace + x <- rle(x) + } + x$values[x$values==na_replace] <- NA_integer_ + tibble::tibble(value=x$values, + offset=c(0,cumsum(x$lengths)[-length(x$lengths)]), + datasize=x$lengths) +} + + +ls_h5 <- function(filename,groupname="/",full_names=FALSE,details=FALSE){ + if(!details){ fs::path_norm(ls_h5_exp(filename = fs::path_expand(filename), groupname = groupname, full_names = full_names)) + }else{ + full_n <- ls_h5_exp(filename = fs::path_expand(filename), + groupname = groupname, + full_names = TRUE) + id_type=purrr::map_chr(full_n,~typeof_h5(filename,.x)) + id_dim=purrr::map(full_n,~dim_h5(filename,.x)) + if(all(lengths(id_dim)==length(id_dim[[1]]))){ + id_dim <- purrr::flatten_int(id_dim) + } + if(!full_names){ + full_n <- fs::path_rel(full_n,start=groupname) + } + tibble::tibble(name=full_n,dims=id_dim,type=id_type) + } } construct_data_path <- function(...){ @@ -33,20 +88,14 @@ isObject_h5 <- function(filename,datapath){ return(ret) } -## gen_matslice_chunk_l <- function(input_rows,chunksize=10000,...){ -## output_l <- BBmisc::chunk(input_rows,chunk.size=chunksize) %>% purrr::map(~tibble::data_frame(input_rows=.x)afunction(x){ -## stopifnot(all(x==seq(x[1],x[length(x)]))) -## return(data_frame(row_offsets=x[1]-1,row_chunksizes=length(x))) -## }) %>% dplyr::mutate(...) -## return(input_df) -## } + gen_matslice_df <- function(filename,group_prefix,dataname){ sub_grps <- ls_h5(filename,group_prefix) retdf <- dplyr::data_frame(filenames=filename, groupnames=paste0(group_prefix,"/",sub_grps), - datanames=dataname) %>% arrange(as.integer(sub_grps)) + datanames=dataname) %>% dplyr::arrange(as.integer(sub_grps)) return(retdf) } @@ -106,7 +155,7 @@ write_l_h5 <- function(data,filename,datapath,...){ if(datapath=="/"){ datapath <- "" } - purrr::iwalk(datal,~write_h5(filename,normalizePath(paste(datapath,.y,sep="/"),mustWork = F),data = .x)) + purrr::iwalk(datal,~write_h5(filename,fix_paths(datapath,.y),data = .x)) } @@ -211,3 +260,59 @@ create_mat_l <- function(dff){ } + + +#' Convert to HDF5 with a custom callback +#' +#' @param input_file +#' @param output_file +#' @param h5_args ... args for write_df_h5 unpacked and passed to `callback_fun` +#' @param callback_fun function with signature matching function(df,filename,datapath,...) (defaults to `write_df_h5`) +#' @param ... +#' +#' @return +#' @export +#' +#' @examples +#' +#' temp_h5 <- fs::file_temp(ext="h5") +#' delim2h5(readr::readr_example("mtcars.csv"),temp_h5,delim="/") +#' new_data <- read_df_h5(temp_h5) + +delim2h5 <- function(input_file, output_file, h5_args = list(datapath = "/"), callback_fun = write_df_h5, id_col = NULL, ...){ + h5_args[["append"]] <- TRUE + callback_args <- formalArgs(callback_fun) + stopifnot(all.equal(callback_args, formalArgs(write_df_h5))) + + h5_args[["append"]] <- TRUE + if (is.null(id_col) || isFALSE(id_col)) { + + wf <- function(x, pos) + rlang::exec(callback_fun, df = x, filename = output_file, !!!h5_args) + + }else { + if (is.character(id_col)) { + + stopifnot(length(id_col) == 1) + wf <- function(x, pos) { + pos_seq <- seq(from = pos, length.out = nrow(x)) + rlang::exec(callback_fun, + df = dplyr::mutate(x, {{id_col}} := pos_seq), + filename = output_file, !!!h5_args) + } + + }else { + stopifnot(isTRUE(id_col)) + wf <- function(x, pos) { + pos_seq <- seq(from = pos, length.out = nrow(x)) + rlang::exec(callback_fun, + df = dplyr::mutate(x, id_col = pos_seq), + filename = output_file, !!!h5_args) + } + + } + } + + + readr::read_delim_chunked(file = input_file, callback = readr::SideEffectChunkCallback$new(wf), ...) +} diff --git a/configure b/configure new file mode 100755 index 0000000..be19a61 --- /dev/null +++ b/configure @@ -0,0 +1,5700 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for EigenH5 0.1.0. +# +# Report bugs to . +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and +$0: nwknoblauch@gmail.com about your system, including any +$0: error possibly output before this message. Then install +$0: a modern shell, or manually run the script under such a +$0: shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='EigenH5' +PACKAGE_TARNAME='eigenh5' +PACKAGE_VERSION='0.1.0' +PACKAGE_STRING='EigenH5 0.1.0' +PACKAGE_BUGREPORT='nwknoblauch@gmail.com' +PACKAGE_URL='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +HDF5R_CFLAGS +DEFINE_H5FREE_MEMORY +HDF5_VERSION_USE +HDF5_FLIBS +HDF5_FFLAGS +HDF5_FC +HDF5_LIBS +HDF5_LDFLAGS +HDF5_CPPFLAGS +HDF5_CFLAGS +HDF5_CC +HDF5_REVISION_VERSION +HDF5_VERSION +H5FC +EGREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +H5CC +HDF5_MINOR_VERSION +HDF5_MAJOR_VERSION +HDF5R_CPPFLAGS +HDF5R_LIBS +SED +AWK +GREP +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +with_hdf5 +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures EigenH5 0.1.0 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/eigenh5] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of EigenH5 0.1.0:";; + esac + cat <<\_ACEOF + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-hdf5=yes/no/PATH location of h5cc or h5pcc for HDF5 configuration + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +EigenH5 configure 0.1.0 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ------------------------------------ ## +## Report this to nwknoblauch@gmail.com ## +## ------------------------------------ ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by EigenH5 $as_me 0.1.0, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_lib_hdf5.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIB_HDF5([serial/parallel]) +# +# DESCRIPTION +# +# This macro provides tests of the availability of HDF5 library. +# +# The optional macro argument should be either 'serial' or 'parallel'. The +# former only looks for serial HDF5 installations via h5cc. The latter +# only looks for parallel HDF5 installations via h5pcc. If the optional +# argument is omitted, serial installations will be preferred over +# parallel ones. +# +# The macro adds a --with-hdf5 option accepting one of three values: +# +# no - do not check for the HDF5 library. +# yes - do check for HDF5 library in standard locations. +# path - complete path to the HDF5 helper script h5cc or h5pcc. +# +# If HDF5 is successfully found, this macro calls +# +# AC_SUBST(HDF5_VERSION) +# AC_SUBST(HDF5_CC) +# AC_SUBST(HDF5_CFLAGS) +# AC_SUBST(HDF5_CPPFLAGS) +# AC_SUBST(HDF5_LDFLAGS) +# AC_SUBST(HDF5_LIBS) +# AC_SUBST(HDF5_FC) +# AC_SUBST(HDF5_FFLAGS) +# AC_SUBST(HDF5_FLIBS) +# AC_DEFINE(HAVE_HDF5) +# +# and sets with_hdf5="yes". Additionally, the macro sets +# with_hdf5_fortran="yes" if a matching Fortran wrapper script is found. +# Note that Autconf's Fortran support is not used to perform this check. +# H5CC and H5FC will contain the appropriate serial or parallel HDF5 +# wrapper script locations. +# +# If HDF5 is disabled or not found, this macros sets with_hdf5="no" and +# with_hdf5_fortran="no". +# +# Your configuration script can test $with_hdf to take any further +# actions. HDF5_{C,CPP,LD}FLAGS may be used when building with C or C++. +# HDF5_F{FLAGS,LIBS} should be used when building Fortran applications. +# +# To use the macro, one would code one of the following in "configure.ac" +# before AC_OUTPUT: +# +# 1) dnl Check for HDF5 support +# AX_LIB_HDF5() +# +# 2) dnl Check for serial HDF5 support +# AX_LIB_HDF5([serial]) +# +# 3) dnl Check for parallel HDF5 support +# AX_LIB_HDF5([parallel]) +# +# One could test $with_hdf5 for the outcome or display it as follows +# +# echo "HDF5 support: $with_hdf5" +# +# You could also for example, override the default CC in "configure.ac" to +# enforce compilation with the compiler that HDF5 uses: +# +# AX_LIB_HDF5([parallel]) +# if test "$with_hdf5" = "yes"; then +# CC="$HDF5_CC" +# else +# AC_MSG_ERROR([Unable to find HDF5, we need parallel HDF5.]) +# fi +# +# LICENSE +# +# Copyright (c) 2009 Timothy Brown +# Copyright (c) 2010 Rhys Ulerich +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 12 + +# This code was adapted by Holger Hoefling on May 2nd 2016 to also +# substitute variables HDF5_MAJOR_VERSION, HDF5_MINOR_VERSION +# as well as HDF5_REVISION_VERSION so that the 3 parts of the +# version number are available separately for testing +# Also changed to check for hdf5_hl header library existence + + + + + +############################################################################# +## +## Copyright 2016 Novartis Institutes for BioMedical Research Inc. +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +############################################################################# + + + +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_compare_version.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# +# DESCRIPTION +# +# This macro compares two version strings. Due to the various number of +# minor-version numbers that can exist, and the fact that string +# comparisons are not compatible with numeric comparisons, this is not +# necessarily trivial to do in a autoconf script. This macro makes doing +# these comparisons easy. +# +# The six basic comparisons are available, as well as checking equality +# limited to a certain number of minor-version levels. +# +# The operator OP determines what type of comparison to do, and can be one +# of: +# +# eq - equal (test A == B) +# ne - not equal (test A != B) +# le - less than or equal (test A <= B) +# ge - greater than or equal (test A >= B) +# lt - less than (test A < B) +# gt - greater than (test A > B) +# +# Additionally, the eq and ne operator can have a number after it to limit +# the test to that number of minor versions. +# +# eq0 - equal up to the length of the shorter version +# ne0 - not equal up to the length of the shorter version +# eqN - equal up to N sub-version levels +# neN - not equal up to N sub-version levels +# +# When the condition is true, shell commands ACTION-IF-TRUE are run, +# otherwise shell commands ACTION-IF-FALSE are run. The environment +# variable 'ax_compare_version' is always set to either 'true' or 'false' +# as well. +# +# Examples: +# +# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) +# AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) +# +# would both be true. +# +# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) +# AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) +# +# would both be false. +# +# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) +# +# would be true because it is only comparing two minor versions. +# +# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) +# +# would be true because it is only comparing the lesser number of minor +# versions of the two values. +# +# Note: The characters that separate the version numbers do not matter. An +# empty string is the same as version 0. OP is evaluated by autoconf, not +# configure, so must be a string, not a variable. +# +# The author would like to acknowledge Guido Draheim whose advice about +# the m4_case and m4_ifvaln functions make this macro only include the +# portions necessary to perform the specific comparison specified by the +# OP argument in the final configure script. +# +# LICENSE +# +# Copyright (c) 2008 Tim Toolan +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 11 + + + +RHDF5LIB_INSTALLED=$(echo 'cat(suppressWarnings(require(Rhdf5lib, quietly=TRUE, character.only=FALSE, warn.conflicts=FALSE)))' | "${R_HOME}/bin/R" --vanilla --slave) + + # Extract the first word of "ggrep", so it can be a program name with args. +set dummy ggrep; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$GREP"; then + ac_cv_prog_GREP="$GREP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_GREP="`which ggrep`" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_GREP" && ac_cv_prog_GREP="`which grep`" +fi +fi +GREP=$ac_cv_prog_GREP +if test -n "$GREP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GREP" >&5 +$as_echo "$GREP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "gawk", so it can be a program name with args. +set dummy gawk; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="`which gawk`" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_AWK" && ac_cv_prog_AWK="`which awk`" +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +if test -n "$AWK"; then + echo "found awk and it's $AWK" +else + echo "no awk!" + exit 1 +fi + + +if test "$RHDF5LIB_INSTALLED" == "TRRUE"; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Found RHDF5LIB: $RHDF5LIB_INSTALLED" >&5 +$as_echo "Found RHDF5LIB: $RHDF5LIB_INSTALLED" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if ${ac_cv_path_SED+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_SED" || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + + + + + + + + + +with_rhdf5lib="yes" +HDF5R_LIBS=$(echo 'cat(Rhdf5lib::pkgconfig("PKG_C_HL_LIBS"))' | "${R_HOME}/bin/R" --vanilla --slave) +HDF5R_CPPFLAGS=$(echo 'cat("-I",system.file("include/",package = "Rhdf5lib"))' | "${R_HOME}/bin/R" --vanilla --slave) +HDF5_VERSION=$(echo 'cat(Rhdf5lib::getHdf5Version())' | "${R_HOME}/bin/R" --vanilla --slave) +HDF5_MAJOR_VERSION=$(echo $HDF5_VERSION | $AWK -F \. '{print $1}') +HDF5_MINOR_VERSION=$(echo $HDF5_VERSION | $AWK -F \. {'print $2'}) +HDF5_REVISION_VERSION=$(echo $HDF5_VERSION | $AWK -F \. {'print $3'}) +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Found Rhdf5lib with version: $HDF5_MAJOR_VERSION.$HDF5_MINOR_VERSION" >&5 +$as_echo "Found Rhdf5lib with version: $HDF5_MAJOR_VERSION.$HDF5_MINOR_VERSION" >&6; } + + + + + + + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Did not find Rhdf5lib: $RHDF5LIB_INSTALLED" >&5 +$as_echo "Did not find Rhdf5lib: $RHDF5LIB_INSTALLED" >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + + + + +if test "" = "" ; then + : # Recognized value +elif test "" = "serial" ; then + : # Recognized value +elif test "" = "parallel"; then + : # Recognized value +else + as_fn_error $? " +Unrecognized value for AX_LIB_HDF5 within configure.ac. +If supplied, argument 1 must be either 'serial' or 'parallel'. +" "$LINENO" 5 +fi + + +# Check whether --with-hdf5 was given. +if test "${with_hdf5+set}" = set; then : + withval=$with_hdf5; if test "$withval" = "no"; then + with_hdf5="no" + elif test "$withval" = "yes"; then + with_hdf5="yes" + else + with_hdf5="yes" + H5CC="$withval" + fi +else + with_hdf5="yes" + +fi + + +HDF5_CC="" +HDF5_VERSION="" +HDF5_CFLAGS="" +HDF5_CPPFLAGS="" +HDF5_LDFLAGS="" +HDF5_LIBS="" +HDF5_FC="" +HDF5_FFLAGS="" +HDF5_FLIBS="" + +if test "$with_hdf5" = "yes"; then + if test -z "$H5CC"; then + for ac_prog in h5cc h5pcc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_H5CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $H5CC in + [\\/]* | ?:[\\/]*) + ac_cv_path_H5CC="$H5CC" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_H5CC="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +H5CC=$ac_cv_path_H5CC +if test -n "$H5CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $H5CC" >&5 +$as_echo "$H5CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$H5CC" && break +done + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Using provided HDF5 C wrapper" >&5 +$as_echo_n "checking Using provided HDF5 C wrapper... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $H5CC" >&5 +$as_echo "$H5CC" >&6; } + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HDF5 libraries" >&5 +$as_echo_n "checking for HDF5 libraries... " >&6; } + if test ! -f "$H5CC" || test ! -x "$H5CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: +Unable to locate HDF5 compilation helper scripts 'h5cc' or 'h5pcc'. +Please specify --with-hdf5= as the full path to h5cc or h5pcc. +HDF5 support is being disabled (equivalent to --with-hdf5=no). +" >&5 +$as_echo "$as_me: WARNING: +Unable to locate HDF5 compilation helper scripts 'h5cc' or 'h5pcc'. +Please specify --with-hdf5= as the full path to h5cc or h5pcc. +HDF5 support is being disabled (equivalent to --with-hdf5=no). +" >&2;} + with_hdf5="no" + with_hdf5_fortran="no" + else + HDF5_SHOW=$(eval $H5CC -show) + + HDF5_CC=$(eval $H5CC -show | $AWK '{print $1}') + if test "$HDF5_CC" = "ccache"; then + HDF5_CC=$(eval $H5CC -show | $AWK '{print $2}') + fi + + + HDF5_VERSION=$(eval $H5CC -showconfig | $GREP 'HDF5 Version:' | $AWK '{print $3}') + HDF5_MAJOR_VERSION=$(echo $HDF5_VERSION | $AWK -F \. '{print $1}') + HDF5_MINOR_VERSION=$(echo $HDF5_VERSION | $AWK -F \. {'print $2'}) + HDF5_REVISION_VERSION=$(echo $HDF5_VERSION | $AWK -F \. {'print $3'}) + + HDF5_tmp_flags=$(eval $H5CC -showconfig \ + | $GREP 'FLAGS\|Extra libraries:' \ + | $AWK -F: '{printf("%s "), $2}' ) + + HDF5_tmp_inst=$(eval $H5CC -showconfig \ + | $GREP 'Installation point:' \ + | $AWK '{print $NF}' ) + + HDF5_CPPFLAGS="-I${HDF5_tmp_inst}/include" + + for arg in $HDF5_SHOW $HDF5_tmp_flags ; do + case "$arg" in + -I*) echo $HDF5_CPPFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ + || HDF5_CPPFLAGS="$arg $HDF5_CPPFLAGS" + ;; + -L*) echo $HDF5_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ + || HDF5_LDFLAGS="$arg $HDF5_LDFLAGS" + ;; + -l*) echo $HDF5_LIBS | $GREP -e "$arg" 2>&1 >/dev/null \ + || HDF5_LIBS="$arg $HDF5_LIBS" + ;; + esac + done + + HDF5_LIBS="$HDF5_LIBS -lhdf5" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (version $HDF5_VERSION)" >&5 +$as_echo "yes (version $HDF5_VERSION)" >&6; } + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ax_lib_hdf5_save_CC=$CC + ax_lib_hdf5_save_CPPFLAGS=$CPPFLAGS + ax_lib_hdf5_save_LIBS=$LIBS + ax_lib_hdf5_save_LDFLAGS=$LDFLAGS + CC=$HDF5_CC + CPPFLAGS=$HDF5_CPPFLAGS + LIBS=$HDF5_LIBS + LDFLAGS=$HDF5_LDFLAGS + ac_fn_c_check_header_mongrel "$LINENO" "hdf5.h" "ac_cv_header_hdf5_h" "$ac_includes_default" +if test "x$ac_cv_header_hdf5_h" = xyes; then : + ac_cv_hadf5_h=yes +else + ac_cv_hadf5_h=no +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for H5Fcreate in -lhdf5" >&5 +$as_echo_n "checking for H5Fcreate in -lhdf5... " >&6; } +if ${ac_cv_lib_hdf5_H5Fcreate+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lhdf5 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char H5Fcreate (); +int +main () +{ +return H5Fcreate (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_hdf5_H5Fcreate=yes +else + ac_cv_lib_hdf5_H5Fcreate=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hdf5_H5Fcreate" >&5 +$as_echo "$ac_cv_lib_hdf5_H5Fcreate" >&6; } +if test "x$ac_cv_lib_hdf5_H5Fcreate" = xyes; then : + ac_cv_libhdf5=yes +else + ac_cv_libhdf5=no +fi + + if test "$ac_cv_hadf5_h" = "no" && test "$ac_cv_libhdf5" = "no" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to compile HDF5 test program" >&5 +$as_echo "$as_me: WARNING: Unable to compile HDF5 test program" >&2;} + fi + ac_fn_c_check_header_compile "$LINENO" "hdf5_hl.h" "ac_cv_header_hdf5_hl_h" "#include +" +if test "x$ac_cv_header_hdf5_hl_h" = xyes; then : + ac_cv_hadf5_hl_h=yes +else + ac_cv_hadf5_hl_h=no +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for H5LTpath_valid in -lhdf5_hl" >&5 +$as_echo_n "checking for H5LTpath_valid in -lhdf5_hl... " >&6; } +if ${ac_cv_lib_hdf5_hl_H5LTpath_valid+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lhdf5_hl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char H5LTpath_valid (); +int +main () +{ +return H5LTpath_valid (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_hdf5_hl_H5LTpath_valid=yes +else + ac_cv_lib_hdf5_hl_H5LTpath_valid=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hdf5_hl_H5LTpath_valid" >&5 +$as_echo "$ac_cv_lib_hdf5_hl_H5LTpath_valid" >&6; } +if test "x$ac_cv_lib_hdf5_hl_H5LTpath_valid" = xyes; then : + ac_cv_libhdf5_hl=yes +else + ac_cv_libhdf5_hl=no +fi + + if test "$ac_cv_hadf5_hl_h" = "no" && test "$ac_cv_libhdf5_hl" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to compile HDF5_HL test program" >&5 +$as_echo "$as_me: WARNING: Unable to compile HDF5_HL test program" >&2;} + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lhdf5_hl" >&5 +$as_echo_n "checking for main in -lhdf5_hl... " >&6; } +if ${ac_cv_lib_hdf5_hl_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lhdf5_hl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_hdf5_hl_main=yes +else + ac_cv_lib_hdf5_hl_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hdf5_hl_main" >&5 +$as_echo "$ac_cv_lib_hdf5_hl_main" >&6; } +if test "x$ac_cv_lib_hdf5_hl_main" = xyes; then : + HDF5_LIBS="$HDF5_LIBS -lhdf5_hl" +fi +ac_cv_lib_hdf5_hl=ac_cv_lib_hdf5_hl_main + + + CC=$ax_lib_hdf5_save_CC + CPPFLAGS=$ax_lib_hdf5_save_CPPFLAGS + LIBS=$ax_lib_hdf5_save_LIBS + LDFLAGS=$ax_lib_hdf5_save_LDFLAGS + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for matching HDF5 Fortran wrapper" >&5 +$as_echo_n "checking for matching HDF5 Fortran wrapper... " >&6; } + H5FC=$(eval echo -n $H5CC | $SED -n 's/cc$/fc/p') + if test -x "$H5FC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $H5FC" >&5 +$as_echo "$H5FC" >&6; } + with_hdf5_fortran="yes" + + + for arg in `$H5FC -show` + do + case "$arg" in #( + -I*) echo $HDF5_FFLAGS | $GREP -e "$arg" >/dev/null \ + || HDF5_FFLAGS="$arg $HDF5_FFLAGS" + ;;#( + -L*) echo $HDF5_FFLAGS | $GREP -e "$arg" >/dev/null \ + || HDF5_FFLAGS="$arg $HDF5_FFLAGS" + echo $HDF5_FFLAGS | $GREP -e "-I${arg#-L}" >/dev/null \ + || HDF5_FFLAGS="-I${arg#-L} $HDF5_FFLAGS" + ;; + esac + done + + for arg in $HDF5_LIBS + do + case "$arg" in #( + -lhdf5_hl) HDF5_FLIBS="$HDF5_FLIBS -lhdf5hl_fortran $arg" + ;; #( + -lhdf5) HDF5_FLIBS="$HDF5_FLIBS -lhdf5_fortran $arg" + ;; #( + *) HDF5_FLIBS="$HDF5_FLIBS $arg" + ;; + esac + done + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + with_hdf5_fortran="no" + fi + + + + + + + + + + + + + + +$as_echo "#define HAVE_HDF5 1" >>confdefs.h + + fi +fi + + +fi + + + + + +if test "$with_hdf5" = "yes" || test "$with_rhdf5lib" = "yes"; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Found hdf5 with version: $HDF5_VERSION" >&5 +$as_echo "Found hdf5 with version: $HDF5_VERSION" >&6; } + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$HDF5_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "1.8.13" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + hdf5_version_sufficient="yes" + else as_fn_error $? "The version of hdf5 installed on your system is not sufficient. Please ensure that at least version 1.8.13 is installed" "$LINENO" 5 + fi + +else + as_fn_error $? "hdf5 does not seem to be installed on your platform. + Please install the hdf5 library. + The required HDF5 library files can be installed as follows: + - + - Debian-based (e.g. Debian >= 8.0, Ubuntu >= 15.04): 'sudo apt-get install libhdf5-dev' + - Old Debian-based (e.g Debian < 8.0, Ubuntu < 15.04): Install from source (see INSTALL) + - OS X using Homebrew: 'brew install hdf5' + - RPM-based (e.g Fedora): 'sudo yum install hdf5-devel'" "$LINENO" 5 +fi + + +if test "$hdf5_version_sufficient" = "yes"; then + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$HDF5_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "1.8.13" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + HDF5_VERSION_USE="1_8_14" + fi + + + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$HDF5_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "1.8.14" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + HDF5_VERSION_USE="1_8_14" + fi + + + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$HDF5_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "1.8.16" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + HDF5_VERSION_USE="1_8_16" + fi + + + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$HDF5_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "1.10.0" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + HDF5_VERSION_USE="1_10_0" + fi + + + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$HDF5_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "1.10.2" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + HDF5_VERSION_USE="1_10_2" + fi + + + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$HDF5_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "1.10.3" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + HDF5_VERSION_USE="1_10_3" + fi + + + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$HDF5_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "1.10.4" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + HDF5_VERSION_USE="1_10_3" + fi + + + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$HDF5_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "1.10.5" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + HDF5_VERSION_USE="1_10_5" + fi + +fi + + + + + + + + + +: ${R_HOME=`R RHOME`} +if test -z "${R_HOME}"; then + echo "could not determine R_HOME" + exit 1 +fi + + if test "$with_hdf5" = "yes"; then +if test -z "${LIBS}"; then + # Extract the first word of "ggrep", so it can be a program name with args. +set dummy ggrep; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$GREP"; then + ac_cv_prog_GREP="$GREP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_GREP="`which ggrep`" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_GREP" && ac_cv_prog_GREP="`which grep`" +fi +fi +GREP=$ac_cv_prog_GREP +if test -n "$GREP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GREP" >&5 +$as_echo "$GREP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${GREP} accepts -o" >&5 +$as_echo_n "checking whether ${GREP} accepts -o... " >&6; } + if `echo '' | ${GREP} -o '' >/dev/null 2>&1` + then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "${GREP} does not support option -o" "$LINENO" 5 + fi + + LIBS=`${H5CC} -show | ${GREP} -o "\-L[^[:space:]]\+" | tr "\n" " "` + + + HDF5R_LIBS="${LIBS} -L. -lhdf5_hl -lhdf5 -lz -lm" + +fi + +if test -z "${CPPFLAGS}"; then + # Extract the first word of "ggrep", so it can be a program name with args. +set dummy ggrep; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$GREP"; then + ac_cv_prog_GREP="$GREP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_GREP="`which ggrep`" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_GREP" && ac_cv_prog_GREP="`which grep`" +fi +fi +GREP=$ac_cv_prog_GREP +if test -n "$GREP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GREP" >&5 +$as_echo "$GREP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${GREP} accepts -o" >&5 +$as_echo_n "checking whether ${GREP} accepts -o... " >&6; } + if `echo '' | ${GREP} -o '' >/dev/null 2>&1` + then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "${GREP} does not support option -o" "$LINENO" 5 + fi + + echo 'int main() { return; }' > myconftest.c + + + + HDF5R_CPPFLAGS=`${H5CC} -show -c myconftest.c | ${GREP} -o "\-I[^[:space:]]\+" | tr "\n" " "` + + rm -f myconftest.c +fi + +fi +HDF5R_CFLAGS="" + + + + +ac_config_files="$ac_config_files src/Makevars" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by EigenH5 $as_me 0.1.0, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +EigenH5 config.status 0.1.0 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + + +eval set X " :F $CONFIG_FILES " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/configure.ac b/configure.ac index 233d0f2..dbf01ea 100644 --- a/configure.ac +++ b/configure.ac @@ -1,185 +1,172 @@ -# Process this file with autoconf to produce a configure script. -# author: Nicholas Knoblauch (nwknoblauch@gmail.com) -AC_PREREQ([2.65]) -AC_INIT([EigenH5], [1.2], [nwknoblauch@gmail.com]) -#AC_CONFIG_SRCDIR([src]) +AC_INIT([EigenH5], 0.1.0, [nwknoblauch@gmail.com]) +dnl Grab that macro that checks for HDF5 availability +m4_include([inst/m4/ax_lib_hdf5.m4]) +m4_include([inst/m4/hh_hdf5rlib.m4]) +m4_include([inst/m4/ax_compare_version.m4]) -#m4_include([inst/m4/ax_lib_hdf5.m4]) -#m4_include([inst/m4/ax_compare_version.m4]) -#m4_include([inst/m4/hh_hdf5rlib.m4]) +RHDF5LIB_INSTALLED=$(echo 'cat(suppressWarnings(require(Rhdf5lib, quietly=TRUE, character.only=FALSE, warn.conflicts=FALSE)))' | "${R_HOME}/bin/R" --vanilla --slave) + AC_CHECK_PROG(GREP,ggrep,`which ggrep`, `which grep`) +AC_CHECK_PROG(AWK,gawk,`which gawk`, `which awk`) -#AX_LIB_HDF5() - - -dnl if test "$with_hdf5" = "yes"; then -dnl AC_MSG_RESULT([Found hdf5 with version: $HDF5_VERSION]) -dnl AX_COMPARE_VERSION([$HDF5_VERSION], [ge], [1.10.2], [hdf5_version_sufficient="yes"], AC_MSG_ERROR([The version of hdf5 installed on your system is not sufficient. Please ensure that at least version 1.10.2 is installed])) -dnl else -dnl AC_MSG_ERROR([hdf5 does not seem to be installed on your platform. -dnl Please install the hdf5 library. -dnl The required HDF5 library files can be installed using conda 'conda install -c crerecombinase r-eigenh5']) -dnl fi - - -LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS` - -# mkdir _build -# wget "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.2/src/hdf5-1.10.2.tar.gz" -o _build/hdf5-1.10.2.tar.gz -# tar -xvzf _build/hdf5-1.10.2.tar.gz -O _build/ -# _build/hdf5-1.10.2/configure --enable-build-mode=production --with-default-plugindir=inst/plugin/ - -#PKG_CHECK_MODULES([blosc] - -dnl if test "$hdf5_version_sufficient" = "yes"; then -dnl AX_COMPARE_VERSION( -dnl [$HDF5_VERSION], -dnl [ge], -dnl [1.10.3], -dnl [HDF5_VERSION_USE="1_10_3"]) -dnl fi - -dnl AC_SUBST(HDF5_VERSION_USE) -dnl AC_SUBST(DEFINE_H5FREE_MEMORY) - -dnl Now find the compiler and compiler flags to use -: ${R_HOME=`R RHOME`} -if test -z "${R_HOME}"; then - echo "could not determine R_HOME" - exit 1 +if test -n "$AWK"; then + echo "found awk and it's $AWK" +else + echo "no awk!" + exit 1 fi +if test "$RHDF5LIB_INSTALLED" == "TRUE"; then -dnl if test -z "${BLOSC_LIBS}"; then -dnl BLOSC_CFLAGS = `echo 'libblosc::pkgconfig("PKG_CFLAGS")'| "${R_HOME}/bin/R" --vanilla --slave` -dnl BLOSC_LIBS = `echo 'libblosc::pkgconfig("PKG_LIBS_static")' | "${R_HOME}/bin/R" --vanilla --slave` -dnl fi -dnl AC_MSG_RESULT([looking for .pc files in $PKG_CONFIG_PATH]) - -dnl PKG_CHECK_MODULES([BLOSC], [blosc], [ -dnl LIBS="${BLOSC_LIBS} ${LIBS}" -dnl AC_MSG_RESULT([found the blosc package: $BLOSC_LIBS])],[ -dnl ]) + AC_MSG_RESULT([Found RHDF5LIB: $RHDF5LIB_INSTALLED]) + HH_HDF5RLIB() +else + AC_MSG_RESULT([Did not find Rhdf5lib: $RHDF5LIB_INSTALLED]) + AX_LIB_HDF5() -dnl PKG_CHECK_MODULES([HDF5], [hdf5], [ -dnl LIBS="${HDF5_LIBS} ${LIBS}" -dnl AC_MSG_RESULT([found the hdf5 package: $HDF5_LIBS])],[ -dnl ]) - -if test -z "{HDF5_LIBS}"; then - HDF5_LIBS = `echo 'Rhdf5lib::pkgconfig("PKG_C_LIBS")'|\ - "${R_HOME}/bin/R" --vanilla --slave` fi -dnl PKG_CHECK_MODULES([LZF], [lzf], [ -dnl LIBS="${LZF_LIBS} ${LIBS}" -dnl AC_MSG_RESULT([found the lzf package: LZF_LIBS])],[ -dnl AC_MSG_ERROR([unable to find the lzf package]) -dnl ]) - -dnl PKG_CHECK_MODULES([ZSTD], [zstd], [ -dnl LIBS="${ZSTD_LIBS} ${LIBS}" -dnl AC_MSG_RESULT([found the zstd package: $ZSTD_LIBS])],[ -dnl AC_MSG_ERROR([unable to find the zstd package]) -dnl ]) -dnl AC_SEARCH_LIBS([H5open], [hdf5], [], [ -dnl AC_MSG_ERROR([hdf5 open function]) -dnl ]) - -dnl AC_SEARCH_LIBS([H5Oget_info_by_name], [hdf5], [], [ -dnl AC_MSG_ERROR([hdf5 info_by_name]) -dnl ]) - - -dnl if test -z "${BLOSC_LIBS}"; then -dnl AC_SEARCH_LIBS([blosc_compress], [blosc], [], [ -dnl AC_MSG_ERROR([unable to find the blosc_compress() function]) -dnl ]) -dnl fi - -dnl if test -z "${ZSTD_LIBS}"; then -dnl AC_SEARCH_LIBS([ZSTD_compress], [zstd], [], [ -dnl AC_MSG_ERROR([unable to find the ZSTD_compress() function]) -dnl ]) -dnl fi - -dnl AC_SEARCH_LIBS([std::filesystem::path::path],[std++fs],[],[ -dnl AC_MSG_ERROR([unable to find the c++ filesystem library]) -dnl ]) +if test "$with_hdf5" = "yes" || test "$with_rhdf5lib" = "yes"; then +AC_MSG_RESULT([Found hdf5 with version: $HDF5_VERSION]) +AX_COMPARE_VERSION([$HDF5_VERSION], [ge], [1.8.13], [hdf5_version_sufficient="yes"], AC_MSG_ERROR([The version of hdf5 installed on your system is not sufficient. Please ensure that at least version 1.8.13 is installed])) +else + AC_MSG_ERROR([hdf5 does not seem to be installed on your platform. + Please install the hdf5 library. + The required HDF5 library files can be installed as follows: + - + - Debian-based (e.g. Debian >= 8.0, Ubuntu >= 15.04): 'sudo apt-get install libhdf5-dev' + - Old Debian-based (e.g Debian < 8.0, Ubuntu < 15.04): Install from source (see INSTALL) + - OS X using Homebrew: 'brew install hdf5' + - RPM-based (e.g Fedora): 'sudo yum install hdf5-devel']) +fi +if test "$hdf5_version_sufficient" = "yes"; then + AX_COMPARE_VERSION( + [$HDF5_VERSION], + [ge], + [1.8.13], + [HDF5_VERSION_USE="1_8_14"]) + + AX_COMPARE_VERSION( + [$HDF5_VERSION], + [ge], + [1.8.14], + [HDF5_VERSION_USE="1_8_14"]) + + AX_COMPARE_VERSION( + [$HDF5_VERSION], + [ge], + [1.8.16], + [HDF5_VERSION_USE="1_8_16"]) + + AX_COMPARE_VERSION( + [$HDF5_VERSION], + [ge], + [1.10.0], + [HDF5_VERSION_USE="1_10_0"]) + + AX_COMPARE_VERSION( + [$HDF5_VERSION], + [ge], + [1.10.2], + [HDF5_VERSION_USE="1_10_2"]) + + AX_COMPARE_VERSION( + [$HDF5_VERSION], + [ge], + [1.10.3], + [HDF5_VERSION_USE="1_10_3"]) + + AX_COMPARE_VERSION( + [$HDF5_VERSION], + [ge], + [1.10.4], + [HDF5_VERSION_USE="1_10_3"]) + + AX_COMPARE_VERSION( + [$HDF5_VERSION], + [ge], + [1.10.5], + [HDF5_VERSION_USE="1_10_5"]) +fi -AC_MSG_RESULT([Libs will be : $LIBS]) -AC_MSG_RESULT([HDF5Libs will be : $HDF5_LIBS]) -AC_SUBST(LIBS) -#AC_SUBST(BLOSC_LIBS) -#AC_SUBST(BLOSC_CFLAGS) -AC_SUBST(HDF5_LIBS) -#AC_SUBST(BLOSC_CFLAGS) +AC_SUBST(HDF5_VERSION_USE) +AC_SUBST(DEFINE_H5FREE_MEMORY) -dnl if test -z "${LIBS}"; then -dnl dnl prefer ggrep if installed -dnl AC_CHECK_PROG(GREP,ggrep,`which ggrep`, `which grep`) -dnl dnl check if $GREP supports option -o -dnl AC_MSG_CHECKING([whether ${GREP} accepts -o]) -dnl if `echo '' | ${GREP} -o '' >/dev/null 2>&1` -dnl then -dnl AC_MSG_RESULT([yes]) -dnl else -dnl AC_MSG_RESULT([no]) -dnl AC_MSG_ERROR([${GREP} does not support option -o]) -dnl fi -dnl [ -dnl LIBS=`${H5CC} -show | ${GREP} -o "\-L[^[:space:]]\+" | tr "\n" " "` -dnl ] +dnl Now find the compiler and compiler flags to use +: ${R_HOME=`R RHOME`} +if test -z "${R_HOME}"; then + echo "could not determine R_HOME" + exit 1 +fi -dnl dnl Fix for newer Debian versions -dnl HDF5R_LIBS="${LIBS} -L. -lhdf5_hl -lhdf5 -lz -lm" + if test "$with_hdf5" = "yes"; then +if test -z "${LIBS}"; then + dnl prefer ggrep if installed + AC_CHECK_PROG(GREP,ggrep,`which ggrep`, `which grep`) + + dnl check if $GREP supports option -o + AC_MSG_CHECKING([whether ${GREP} accepts -o]) + if `echo '' | ${GREP} -o '' >/dev/null 2>&1` + then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([${GREP} does not support option -o]) + fi + [ + LIBS=`${H5CC} -show | ${GREP} -o "\-L[^[:space:]]\+" | tr "\n" " "` + ] + + dnl Fix for newer Debian versions + HDF5R_LIBS="${LIBS} -L. -lhdf5_hl -lhdf5 -lz -lm" -dnl fi +fi -dnl if test -z "${CPPFLAGS}"; then -dnl dnl prefer ggrep if installed -dnl AC_CHECK_PROG(GREP,ggrep,`which ggrep`, `which grep`) +if test -z "${CPPFLAGS}"; then + dnl prefer ggrep if installed + AC_CHECK_PROG(GREP,ggrep,`which ggrep`, `which grep`) -dnl dnl check if $GREP supports option -o -dnl AC_MSG_CHECKING([whether ${GREP} accepts -o]) -dnl if `echo '' | ${GREP} -o '' >/dev/null 2>&1` -dnl then -dnl AC_MSG_RESULT([yes]) -dnl else -dnl AC_MSG_RESULT([no]) -dnl AC_MSG_ERROR([${GREP} does not support option -o]) -dnl fi + dnl check if $GREP supports option -o + AC_MSG_CHECKING([whether ${GREP} accepts -o]) + if `echo '' | ${GREP} -o '' >/dev/null 2>&1` + then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([${GREP} does not support option -o]) + fi -dnl echo 'int main() { return; }' > myconftest.c + echo 'int main() { return; }' > myconftest.c -dnl [ -dnl HDF5R_CPPFLAGS=`${H5CC} -show -c myconftest.c | ${GREP} -o "\-I[^[:space:]]\+" | tr "\n" " "` -dnl ] -dnl rm -f myconftest.c -dnl fi + [ + HDF5R_CPPFLAGS=`${H5CC} -show -c myconftest.c | ${GREP} -o "\-I[^[:space:]]\+" | tr "\n" " "` + ] + rm -f myconftest.c +fi +fi dnl dummy substitute HDF5R_CFLAGS -#HDF5R_CFLAGS="" -#AC_SUBST(HDF5R_CFLAGS) +HDF5R_CFLAGS="" +AC_SUBST(HDF5R_CFLAGS) dnl substitute CPPFLAGS and LIBS -#AC_SUBST(HDF5R_CPPFLAGS) -#AC_SUBST(HDF5R_LIBS) -dnl and do subsitution in the src/Makevars.in +AC_SUBST(HDF5R_CPPFLAGS) +AC_SUBST(HDF5R_LIBS) +dnl and do subsitution in the src/Makevars.in AC_CONFIG_FILES([src/Makevars]) AC_OUTPUT diff --git a/inst/include/EigenH5.h b/inst/include/EigenH5.h index 612cd5e..6d81cb7 100644 --- a/inst/include/EigenH5.h +++ b/inst/include/EigenH5.h @@ -1,15 +1,25 @@ #pragma once +#define ZSTD_STATIC_LINKING_ONLY + #include #include #include #include +#include -#include -#include - -#define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS +#define STRICT_R_HEADERS #include -//#include "path/path.hpp" + + + + +// constexprREV_ACTG <- stats::setNames(c("T", "G", "A", "C"), ACTG) + + +// Snp make_Snp(unsigned char chrom, double pos,char ref, char alt){ +// return Snp{bit_snp + + @@ -61,7 +71,6 @@ class Path{ return (ret); } operator const std::string&() const { return(nodes); } - }; inline std::string operator+(const std::string a, const Path &b){ @@ -74,56 +83,16 @@ inline std::ostream &operator<<(std::ostream &os, const Path &dt) { } #include "highfive/highfive.hpp" -#ifdef USE_BLOSC -#include "blosc_filter.h" -#endif -#include "lzf/lzf_filter.h" -#include "zstd/zstd_h5plugin.h" -#include "zstd/zstd.h" - -#include - -#if __cplusplus < 201402L - -#include -#include -#include -#include -namespace std { - -template struct _Unique_if { - typedef unique_ptr _Single_object; -}; - -template struct _Unique_if { - typedef unique_ptr _Unknown_bound; -}; +#include -template struct _Unique_if { - typedef void _Known_bound; -}; +SEXP read_attribute(const HighFive::Group &der,const std::string attribute_name); +SEXP read_attribute(const HighFive::DataSet &der,const std::string attribute_name); -template -typename _Unique_if::_Single_object - make_unique(Args&&... args) { - return unique_ptr(new T(std::forward(args)...)); - } -template -typename _Unique_if::_Unknown_bound - make_unique(size_t n) { - typedef typename remove_extent::type U; - return unique_ptr(new U[n]()); - } -template -typename _Unique_if::_Known_bound - make_unique(Args&&...) = delete; -} -#endif // using Path = std::string; // using PathNode = std::string; @@ -143,6 +112,10 @@ class FileManager{ void print()const; }; + + + + #include "EigenH5_RcppExports.h" inline Path root_path(const std::string &input) { @@ -178,15 +151,47 @@ struct cpp2r{ HighFive::Filter create_filter(std::vector data_dimensions, Rcpp::List &options); -template boost::optional > get_list_element(const Rcpp::List &list, const std::string name,const bool empty_is_false = true); -template::data_t > boost::optional get_list_scalar(const Rcpp::List &list, const std::string name); -std::vector > parse_subset_list(const Rcpp::List &list,std::vector datadims); +template +std::optional> +get_list_element(const Rcpp::List &list, const std::string name, + const bool empty_is_false = true); + +template +std::optional > get_any_list_element(const Rcpp::List &list, const std::vector name,const bool empty_is_false=true); + + +template::data_t > std::optional get_list_scalar(const Rcpp::List &list, const std::string name); +std::vector > parse_subset_list(const Rcpp::List &list,std::vector datadims); + + +SEXPTYPE typeof_h5_dset(const HighFive::DataSet &dset); + + +inline std::vector list_R_attr(const HighFive::DataSet &dset){ + auto attr_n = dset.listAttributeNames(); + attr_n.erase(std::remove_if(attr_n.begin(),attr_n.end(),[](const std::string& str){ + if(str.size()<=3) + return true; + if(str[0]!='R') + return true; + if(str[1]!=':') + return true; + return false; + })); + return attr_n; +} + + +inline bool has_R_attr(const HighFive::DataSet &dset){ + return !list_R_attr(dset).empty(); +} -inline std::vector > parse_option(const Rcpp::List &list, std::vector datadims,std::string prefix){ - using int_o = boost::optional; +inline std::vector > parse_option(const Rcpp::List &list, std::vector datadims,std::string prefix){ + + using int_o = std::optional; const size_t num_dims= datadims.size(); - std::vector offset_v(num_dims,boost::none); + std::vector offset_v(num_dims,std::nullopt); if(auto offset_o =get_list_element(list,prefix)){ if(offset_o->size()!=num_dims){ Rcpp::stop("subset argument "+prefix+" must satisfy length(offset)==length(dim(data))"); @@ -213,40 +218,16 @@ inline std::vector > parse_option(const Rcpp::List &list, s } - - - -//std::vector > parse_option(const Rcpp::List &list, std::vector datadims,std::string prefix); - - -//std::vector > parse_option(const Rcpp::List &list, std::vector datadims,std::string prefix); -//std::vector > parse_subset_list(const Rcpp::List &list,std::vector datadims); - - - - - - - - - - - -SEXPTYPE h2r_T(hid_t htype); +SEXPTYPE h2r_T(const HighFive::DataType htype); +Rcpp::StringVector h2s_T(const HighFive::DataType htype); bool isGroup(const std::string filename, std::string groupname); - - - - - - template -inline boost::optional > get_list_element(const Rcpp::List &list, const std::string name,const bool empty_is_false){ +inline std::optional > get_list_element(const Rcpp::List &list, const std::string name,const bool empty_is_false){ Rcpp::RObject rnames = list.names(); if(rnames.isNULL()){ - return(boost::none); + return(std::nullopt); } Rcpp::CharacterVector colnames(rnames); for(auto tc:colnames){ @@ -256,25 +237,36 @@ inline boost::optional > get_list_element(const Rcpp::List & if(mvec.size()>0){ return(mvec); }else{ - return(boost::none); + return(std::nullopt); } }else{ return(Rcpp::as >(list[name])); } } } - return(boost::none); + return(std::nullopt); +} + + +template +inline std::optional > get_any_list_element(const Rcpp::List &list, const std::vector name,const bool empty_is_false){ + for(auto el : name){ + if(auto ret = get_list_element(list,el,empty_is_false)) + return ret; + } + return std::nullopt; } -inline std::vector > parse_subset_list(const Rcpp::List &list,std::vector datadims){ - using rvec_o = boost::optional; + +inline std::vector > parse_subset_list(const Rcpp::List &list,std::vector datadims){ + using rvec_o = std::optional; const size_t num_dims= datadims.size(); if(num_dims>2){ Rcpp::stop("Datasets with Dims>2 currently not supported"); } - std::vector retvec(num_dims,boost::none); + std::vector retvec(num_dims,std::nullopt); if(num_dims==1){ if(auto subset_rv =get_list_element(list,"subset")){ retvec[0] = subset_rv.value(); @@ -305,24 +297,24 @@ inline std::vector > parse_subset_list(cons template -inline boost::optional get_list_scalar(const Rcpp::List &list, const std::string name){ +inline std::optional get_list_scalar(const Rcpp::List &list, const std::string name){ if(auto rel = get_list_element(list,name)){ T rel_b = *(Rcpp::as< std::vector >(*rel).begin()); return(rel_b); }else{ - return(boost::none); + return(std::nullopt); } } template - inline boost::optional list_get_any(const Rcpp::List &list, const std::vector name_opts){ + inline std::optional get_list_any(const Rcpp::List &list, std::vector name_opts){ for( auto &name : name_opts){ auto trel = get_list_scalar(list,name); if(trel){ return(trel); } } - return(boost::none); + return(std::nullopt); } @@ -332,6 +324,7 @@ template + std::string get_datapath(const Rcpp::List &list); std::string get_filepath(const Rcpp::List &list); @@ -351,10 +344,14 @@ inline HighFive::DataSet getDataSet (const Rcpp::List file_l, std::unique_ptr #include #include +//#include + + +std::variant>,Rcpp::IntegerVector> dispatch_subset(SEXP x); + diff --git a/inst/include/EigenH5_RcppExports.h b/inst/include/EigenH5_RcppExports.h index 11ac3b1..eed4928 100644 --- a/inst/include/EigenH5_RcppExports.h +++ b/inst/include/EigenH5_RcppExports.h @@ -67,6 +67,48 @@ namespace EigenH5 { return Rcpp::as(rcpp_result_gen); } + inline bool has_blosc() { + typedef SEXP(*Ptr_has_blosc)(); + static Ptr_has_blosc p_has_blosc = NULL; + if (p_has_blosc == NULL) { + validateSignature("bool(*has_blosc)()"); + p_has_blosc = (Ptr_has_blosc)R_GetCCallable("EigenH5", "_EigenH5_has_blosc"); + } + RObject rcpp_result_gen; + { + RNGScope RCPP_rngScope_gen; + rcpp_result_gen = p_has_blosc(); + } + if (rcpp_result_gen.inherits("interrupted-error")) + throw Rcpp::internal::InterruptedException(); + if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) + throw Rcpp::LongjumpException(rcpp_result_gen); + if (rcpp_result_gen.inherits("try-error")) + throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); + return Rcpp::as(rcpp_result_gen); + } + + inline bool has_lzf() { + typedef SEXP(*Ptr_has_lzf)(); + static Ptr_has_lzf p_has_lzf = NULL; + if (p_has_lzf == NULL) { + validateSignature("bool(*has_lzf)()"); + p_has_lzf = (Ptr_has_lzf)R_GetCCallable("EigenH5", "_EigenH5_has_lzf"); + } + RObject rcpp_result_gen; + { + RNGScope RCPP_rngScope_gen; + rcpp_result_gen = p_has_lzf(); + } + if (rcpp_result_gen.inherits("interrupted-error")) + throw Rcpp::internal::InterruptedException(); + if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) + throw Rcpp::LongjumpException(rcpp_result_gen); + if (rcpp_result_gen.inherits("try-error")) + throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); + return Rcpp::as(rcpp_result_gen); + } + inline void start_blosc() { typedef SEXP(*Ptr_start_blosc)(); static Ptr_start_blosc p_start_blosc = NULL; @@ -255,6 +297,27 @@ namespace EigenH5 { return Rcpp::as(rcpp_result_gen); } + inline SEXP read_R_attribute_h5(const std::string& filename, std::string datapath) { + typedef SEXP(*Ptr_read_R_attribute_h5)(SEXP,SEXP); + static Ptr_read_R_attribute_h5 p_read_R_attribute_h5 = NULL; + if (p_read_R_attribute_h5 == NULL) { + validateSignature("SEXP(*read_R_attribute_h5)(const std::string&,std::string)"); + p_read_R_attribute_h5 = (Ptr_read_R_attribute_h5)R_GetCCallable("EigenH5", "_EigenH5_read_R_attribute_h5"); + } + RObject rcpp_result_gen; + { + RNGScope RCPP_rngScope_gen; + rcpp_result_gen = p_read_R_attribute_h5(Shield(Rcpp::wrap(filename)), Shield(Rcpp::wrap(datapath))); + } + if (rcpp_result_gen.inherits("interrupted-error")) + throw Rcpp::internal::InterruptedException(); + if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) + throw Rcpp::LongjumpException(rcpp_result_gen); + if (rcpp_result_gen.inherits("try-error")) + throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); + return Rcpp::as(rcpp_result_gen); + } + inline SEXP read_attribute_h5(const std::string& filename, std::string datapath) { typedef SEXP(*Ptr_read_attribute_h5)(SEXP,SEXP); static Ptr_read_attribute_h5 p_read_attribute_h5 = NULL; @@ -297,6 +360,48 @@ namespace EigenH5 { return Rcpp::as(rcpp_result_gen); } + inline Rcpp::IntegerVector fast_str2int(Rcpp::StringVector input, const int offset = 0, const int na_val = NA_INTEGER) { + typedef SEXP(*Ptr_fast_str2int)(SEXP,SEXP,SEXP); + static Ptr_fast_str2int p_fast_str2int = NULL; + if (p_fast_str2int == NULL) { + validateSignature("Rcpp::IntegerVector(*fast_str2int)(Rcpp::StringVector,const int,const int)"); + p_fast_str2int = (Ptr_fast_str2int)R_GetCCallable("EigenH5", "_EigenH5_fast_str2int"); + } + RObject rcpp_result_gen; + { + RNGScope RCPP_rngScope_gen; + rcpp_result_gen = p_fast_str2int(Shield(Rcpp::wrap(input)), Shield(Rcpp::wrap(offset)), Shield(Rcpp::wrap(na_val))); + } + if (rcpp_result_gen.inherits("interrupted-error")) + throw Rcpp::internal::InterruptedException(); + if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) + throw Rcpp::LongjumpException(rcpp_result_gen); + if (rcpp_result_gen.inherits("try-error")) + throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); + return Rcpp::as(rcpp_result_gen); + } + + inline Rcpp::IntegerVector fast_str2ascii(Rcpp::StringVector input, int offset = 0) { + typedef SEXP(*Ptr_fast_str2ascii)(SEXP,SEXP); + static Ptr_fast_str2ascii p_fast_str2ascii = NULL; + if (p_fast_str2ascii == NULL) { + validateSignature("Rcpp::IntegerVector(*fast_str2ascii)(Rcpp::StringVector,int)"); + p_fast_str2ascii = (Ptr_fast_str2ascii)R_GetCCallable("EigenH5", "_EigenH5_fast_str2ascii"); + } + RObject rcpp_result_gen; + { + RNGScope RCPP_rngScope_gen; + rcpp_result_gen = p_fast_str2ascii(Shield(Rcpp::wrap(input)), Shield(Rcpp::wrap(offset))); + } + if (rcpp_result_gen.inherits("interrupted-error")) + throw Rcpp::internal::InterruptedException(); + if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) + throw Rcpp::LongjumpException(rcpp_result_gen); + if (rcpp_result_gen.inherits("try-error")) + throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); + return Rcpp::as(rcpp_result_gen); + } + inline void link_objects_h5(Rcpp::StringVector filename_from, const std::string filename_to, Rcpp::StringVector datapath_from, Rcpp::StringVector datapath_to) { typedef SEXP(*Ptr_link_objects_h5)(SEXP,SEXP,SEXP,SEXP); static Ptr_link_objects_h5 p_link_objects_h5 = NULL; @@ -482,6 +587,27 @@ namespace EigenH5 { return Rcpp::as(rcpp_result_gen); } + inline int ArrayTypeSize(const std::string filename, std::string dataname) { + typedef SEXP(*Ptr_ArrayTypeSize)(SEXP,SEXP); + static Ptr_ArrayTypeSize p_ArrayTypeSize = NULL; + if (p_ArrayTypeSize == NULL) { + validateSignature("int(*ArrayTypeSize)(const std::string,std::string)"); + p_ArrayTypeSize = (Ptr_ArrayTypeSize)R_GetCCallable("EigenH5", "_EigenH5_ArrayTypeSize"); + } + RObject rcpp_result_gen; + { + RNGScope RCPP_rngScope_gen; + rcpp_result_gen = p_ArrayTypeSize(Shield(Rcpp::wrap(filename)), Shield(Rcpp::wrap(dataname))); + } + if (rcpp_result_gen.inherits("interrupted-error")) + throw Rcpp::internal::InterruptedException(); + if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) + throw Rcpp::LongjumpException(rcpp_result_gen); + if (rcpp_result_gen.inherits("try-error")) + throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); + return Rcpp::as(rcpp_result_gen); + } + inline bool isDataSet(const std::string filename, std::string dataname) { typedef SEXP(*Ptr_isDataSet)(SEXP,SEXP); static Ptr_isDataSet p_isDataSet = NULL; @@ -545,11 +671,11 @@ namespace EigenH5 { return Rcpp::as(rcpp_result_gen); } - inline Rcpp::StringVector typeof_h5(const std::string& filename, const std::string& datapath) { + inline Rcpp::StringVector typeof_h5(const std::string filename, const std::string datapath) { typedef SEXP(*Ptr_typeof_h5)(SEXP,SEXP); static Ptr_typeof_h5 p_typeof_h5 = NULL; if (p_typeof_h5 == NULL) { - validateSignature("Rcpp::StringVector(*typeof_h5)(const std::string&,const std::string&)"); + validateSignature("Rcpp::StringVector(*typeof_h5)(const std::string,const std::string)"); p_typeof_h5 = (Ptr_typeof_h5)R_GetCCallable("EigenH5", "_EigenH5_typeof_h5"); } RObject rcpp_result_gen; @@ -566,6 +692,27 @@ namespace EigenH5 { return Rcpp::as(rcpp_result_gen); } + inline Rcpp::List info_h5(const Rcpp::StringVector filename, Rcpp::StringVector datapaths) { + typedef SEXP(*Ptr_info_h5)(SEXP,SEXP); + static Ptr_info_h5 p_info_h5 = NULL; + if (p_info_h5 == NULL) { + validateSignature("Rcpp::List(*info_h5)(const Rcpp::StringVector,Rcpp::StringVector)"); + p_info_h5 = (Ptr_info_h5)R_GetCCallable("EigenH5", "_EigenH5_info_h5"); + } + RObject rcpp_result_gen; + { + RNGScope RCPP_rngScope_gen; + rcpp_result_gen = p_info_h5(Shield(Rcpp::wrap(filename)), Shield(Rcpp::wrap(datapaths))); + } + if (rcpp_result_gen.inherits("interrupted-error")) + throw Rcpp::internal::InterruptedException(); + if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) + throw Rcpp::LongjumpException(rcpp_result_gen); + if (rcpp_result_gen.inherits("try-error")) + throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); + return Rcpp::as(rcpp_result_gen); + } + inline Rcpp::DataFrame file_acc_ct(const std::string filename) { typedef SEXP(*Ptr_file_acc_ct)(SEXP); static Ptr_file_acc_ct p_file_acc_ct = NULL; diff --git a/inst/include/concepts/concepts.hpp b/inst/include/concepts/concepts.hpp new file mode 100644 index 0000000..37a8bb2 --- /dev/null +++ b/inst/include/concepts/concepts.hpp @@ -0,0 +1,1233 @@ +/// \file +// CPP, the Concepts PreProcessor library +// +// Copyright Eric Niebler 2018-present +// Copyright (c) 2018-present, Facebook, Inc. +// +// Use, modification and distribution is subject to the +// Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. +// +// Project home: https://github.com/ericniebler/range-v3 +// + +#ifndef CPP_CONCEPTS_HPP +#define CPP_CONCEPTS_HPP + +// clang-format off + +#include +#include +#include +#include +#include + +// disable buggy compatibility warning about "requires" and "concept" being +// C++20 keywords. +#if defined(__clang__) || defined(__GNUC__) +#define CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") \ + _Pragma("GCC diagnostic ignored \"-Wpragmas\"") \ + _Pragma("GCC diagnostic ignored \"-Wc++2a-compat\"") \ + _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"") \ + /**/ +#define CPP_PP_IGNORE_CXX2A_COMPAT_END \ + _Pragma("GCC diagnostic pop") +#else +#define CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN +#define CPP_PP_IGNORE_CXX2A_COMPAT_END +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +#define CPP_WORKAROUND_MSVC_779763 // FATAL_UNREACHABLE calling constexpr function via template parameter +#define CPP_WORKAROUND_MSVC_780775 // Incorrect substitution in function template return type +#define CPP_WORKAROUND_MSVC_654601 // Failure to invoke *implicit* bool conversion in a constant expression +#endif + +#if !defined(CPP_CXX_CONCEPTS) +#ifdef CPP_DOXYGEN_INVOKED +#define CPP_CXX_CONCEPTS 201800L +#elif defined(__cpp_concepts) && __cpp_concepts > 0 +// gcc-6 concepts are too buggy to use +#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 7 +#define CPP_CXX_CONCEPTS __cpp_concepts +#else +#define CPP_CXX_CONCEPTS 0L +#endif +#else +#define CPP_CXX_CONCEPTS 0L +#endif +#endif + +CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN + +#define CPP_PP_CHECK(...) CPP_PP_CHECK_N(__VA_ARGS__, 0,) +#define CPP_PP_CHECK_N(x, n, ...) n +#define CPP_PP_PROBE(x) x, 1, +#define CPP_PP_PROBE_N(x, n) x, n, + +// CPP_CXX_VA_OPT +#ifndef CPP_CXX_VA_OPT +#if __cplusplus > 201703L +#define CPP_CXX_VA_OPT_(...) CPP_PP_CHECK(__VA_OPT__(,) 1) +#define CPP_CXX_VA_OPT CPP_CXX_VA_OPT_(~) +#else +#define CPP_CXX_VA_OPT 0 +#endif +#endif // CPP_CXX_VA_OPT + +#define CPP_PP_CAT_(X, ...) X ## __VA_ARGS__ +#define CPP_PP_CAT(X, ...) CPP_PP_CAT_(X, __VA_ARGS__) +#define CPP_PP_CAT2_(X, ...) X ## __VA_ARGS__ +#define CPP_PP_CAT2(X, ...) CPP_PP_CAT2_(X, __VA_ARGS__) + +#define CPP_PP_EVAL(X, ...) X(__VA_ARGS__) +#define CPP_PP_EVAL2(X, ...) X(__VA_ARGS__) + +#define CPP_PP_EXPAND(...) __VA_ARGS__ +#define CPP_PP_EAT(...) + +#define CPP_PP_IS_PAREN(x) CPP_PP_CHECK(CPP_PP_IS_PAREN_PROBE x) +#define CPP_PP_IS_PAREN_PROBE(...) CPP_PP_PROBE(~) + +#define CPP_PP_COUNT(...) \ + CPP_PP_COUNT_(__VA_ARGS__, \ + 50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31, \ + 30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11, \ + 10,9,8,7,6,5,4,3,2,1,) \ + /**/ +#define CPP_PP_COUNT_( \ + _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ + _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ + _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \ + _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \ + _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, N, ...) \ + N \ + /**/ + +#define CPP_PP_IIF(BIT) CPP_PP_CAT_(CPP_PP_IIF_, BIT) +#define CPP_PP_IIF_0(TRUE, ...) __VA_ARGS__ +#define CPP_PP_IIF_1(TRUE, ...) TRUE + +#define CPP_PP_LPAREN ( + +#define CPP_PP_NOT(BIT) CPP_PP_CAT_(CPP_PP_NOT_, BIT) +#define CPP_PP_NOT_0 1 +#define CPP_PP_NOT_1 0 + +#define CPP_PP_EMPTY() +#define CPP_PP_COMMA() , +#define CPP_PP_LBRACE() { +#define CPP_PP_RBRACE() } +#define CPP_PP_COMMA_IIF(X) \ + CPP_PP_IIF(X)(CPP_PP_EMPTY, CPP_PP_COMMA)() \ + /**/ + +#define CPP_assert(...) \ + static_assert(static_cast(__VA_ARGS__), \ + "Concept assertion failed : " #__VA_ARGS__) \ + /**/ +#define CPP_assert_msg static_assert + +#ifdef CPP_WORKAROUND_MSVC_654601 +#define CPP_FORCE_TO_BOOL static_cast +#else +#define CPP_FORCE_TO_BOOL +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +#define CPP_INSTANCE(...) ::concepts::detail::instance_ +#else +#define CPP_INSTANCE(...) __VA_ARGS__ +#endif + +//////////////////////////////////////////////////////////////////////////////// +// CPP_def +// For defining concepts with a syntax similar to C++20. For example: +// +// CPP_def( +// // The assignable_from concept from the C++20 +// template(typename T, typename U) +// concept assignable_from, +// requires (T t, U &&u) ( +// t = (U &&) u, +// ::concepts::requires_> +// ) && +// std::is_lvalue_reference_v +// ); +#define CPP_def(DECL, ...) \ + CPP_PP_EVAL( \ + CPP_PP_DECL_DEF, \ + CPP_PP_CAT(CPP_PP_DEF_DECL_, DECL), \ + __VA_ARGS__) \ + /**/ +#define CPP_PP_DECL_DEF_NAME(...) \ + CPP_PP_CAT(CPP_PP_DEF_, __VA_ARGS__), \ + /**/ +#define CPP_PP_DECL_DEF(TPARAM, NAME, ...) \ + CPP_PP_CAT(CPP_PP_DECL_DEF_, CPP_PP_IS_PAREN(NAME))( \ + TPARAM, \ + NAME, \ + __VA_ARGS__) \ + /**/ +// The defn is of the form: +// template(typename A, typename B = void, typename... Rest) +// (concept Name)(A, B, Rest...), +// // requirements... +#define CPP_PP_DECL_DEF_1(TPARAM, NAME, ...) \ + CPP_PP_EVAL2( \ + CPP_PP_DECL_DEF_IMPL, \ + TPARAM, \ + CPP_PP_DECL_DEF_NAME NAME, \ + __VA_ARGS__) \ + /**/ +// The defn is of the form: +// template(typename A, typename B) +// concept Name, +// // requirements... +// Compute the template arguments (A, B) from the template introducer. +#define CPP_PP_DECL_DEF_0(TPARAM, NAME, ...) \ + CPP_PP_DECL_DEF_IMPL( \ + TPARAM, \ + CPP_PP_CAT(CPP_PP_DEF_, NAME), \ + (CPP_PP_CAT(CPP_PP_AUX_, TPARAM)), \ + __VA_ARGS__) \ + /**/ +// Expand the template definition into a struct and template alias like: +// struct NameConcept { +// template +// static auto Requires_(/* args (optional)*/) -> +// decltype(/*requirements...*/); +// template +// static constexpr auto is_satisfied_by(int) -> +// decltype(bool(&Requires_)) { return true; } +// template +// static constexpr bool is_satisfied_by(long) { return false; } +// }; +// template +// inline constexpr bool Name = NameConcept::is_satisfied_by(0); +#if CPP_CXX_CONCEPTS +// No requires expression +#define CPP_PP_DEF_IMPL_0(...) \ + __VA_ARGS__ \ + /**/ +// Requires expression +#define CPP_PP_DEF_IMPL_1(...) \ + CPP_PP_CAT(CPP_PP_DEF_IMPL_1_, __VA_ARGS__) \ + /**/ +#define CPP_PP_DEF_IMPL_1_requires \ + requires CPP_PP_DEF_IMPL_1_REQUIRES \ + /**/ +#define CPP_PP_DEF_IMPL_1_REQUIRES(...) \ + (__VA_ARGS__) CPP_PP_DEF_IMPL_1_REQUIRES_BODY \ + /**/ +#define CPP_PP_DEF_IMPL_1_REQUIRES_BODY(...) \ + { __VA_ARGS__; } \ + /**/ +#ifdef CPP_DOXYGEN_INVOKED +#define CPP_PP_DECL_DEF_IMPL(TPARAM, NAME, ARGS, ...) \ + CPP_PP_CAT(CPP_PP_DEF_, TPARAM) \ + META_CONCEPT NAME = CPP_PP_DEF_IMPL(__VA_ARGS__,)(__VA_ARGS__) \ + /**/ +#else +#define CPP_PP_DECL_DEF_IMPL(TPARAM, NAME, ARGS, ...) \ + namespace defer { \ + CPP_PP_CAT(CPP_PP_DEF_, TPARAM) \ + META_CONCEPT NAME = CPP_PP_DEF_IMPL(__VA_ARGS__,)(__VA_ARGS__); \ + } \ + using defer::NAME \ + /**/ +#endif +#else +// No requires expression: +#define CPP_PP_DEF_IMPL_0(...) \ + () -> std::enable_if_t \ + /**/ +// Requires expression: +#define CPP_PP_DEF_IMPL_1(...) \ + CPP_PP_CAT(CPP_PP_DEF_IMPL_1_, __VA_ARGS__) ) , int> \ + /**/ +#define CPP_PP_DEF_IMPL_1_requires(...) \ + (__VA_ARGS__) -> \ + std::enable_if_t() \ + /**/ +#ifdef CPP_WORKAROUND_MSVC_780775 +#define CPP_PP_DECL_DEF_IMPL_HACK(ARGS) \ + template) = nullptr> \ + static constexpr bool impl(int) noexcept { return true; } \ + /**/ +#else +#define CPP_PP_DECL_DEF_IMPL_HACK(ARGS) \ + template \ + static constexpr decltype( \ + &C_::template Requires_, true) \ + impl(int) noexcept { return true; } \ + /**/ +#endif +#define CPP_PP_DECL_DEF_IMPL(TPARAM, NAME, ARGS, ...) \ + namespace cpp_detail_ { \ + struct CPP_PP_CAT(NAME, _concept) { \ + using Concept = CPP_PP_CAT(NAME, _concept); \ + CPP_PP_IGNORE_CXX2A_COMPAT_BEGIN \ + CPP_PP_CAT(CPP_PP_DEF_, TPARAM) \ + static auto Requires_ CPP_PP_DEF_IMPL(__VA_ARGS__,)(__VA_ARGS__); \ + CPP_PP_IGNORE_CXX2A_COMPAT_END \ + CPP_PP_CAT(CPP_PP_DEF_, TPARAM) \ + struct Eval { \ + CPP_PP_DECL_DEF_IMPL_HACK(ARGS) \ + static constexpr bool impl(long) noexcept { return false; } \ + constexpr operator bool() const noexcept { \ + return Eval::impl(0); \ + } \ + constexpr auto operator!() const noexcept \ + -> ::concepts::detail::not_ { \ + return {}; \ + } \ + template \ + constexpr auto operator&&(That) const noexcept \ + -> ::concepts::detail::and_ { \ + static_assert( \ + !META_IS_SAME(That, bool), \ + "All expressions in a conjunction should be " \ + "defer:: concepts"); \ + return {}; \ + } \ + template \ + constexpr auto operator||(That) const noexcept \ + -> ::concepts::detail::or_ { \ + static_assert( \ + !META_IS_SAME(That, bool), \ + "All expressions in a disjunction should be " \ + "defer:: concepts"); \ + return {}; \ + } \ + }; \ + }; \ + } \ + namespace defer { \ + CPP_PP_CAT(CPP_PP_DEF_, TPARAM) \ + CPP_INLINE_VAR constexpr auto NAME = \ + cpp_detail_::CPP_PP_CAT(NAME, _concept)::Eval{};\ + } \ + CPP_PP_CAT(CPP_PP_DEF_, TPARAM) \ + CPP_INLINE_VAR constexpr bool NAME = \ + (bool) defer::NAME; \ + using _concepts_int_ = int \ + /**/ +#endif + +#define CPP_PP_REQUIRES_PROBE_requires \ + CPP_PP_PROBE(~) \ + /**/ +#define CPP_PP_DEF_IMPL(REQUIRES, ...) \ + CPP_PP_CAT( \ + CPP_PP_DEF_IMPL_IS_PAREN_, \ + CPP_PP_IS_PAREN(REQUIRES))(REQUIRES) \ + /**/ +#define CPP_PP_DEF_IMPL_IS_PAREN_0(REQUIRES) \ + CPP_PP_CAT( \ + CPP_PP_DEF_IMPL_, \ + CPP_PP_CHECK(CPP_PP_CAT(CPP_PP_REQUIRES_PROBE_, REQUIRES))) \ + /**/ +#define CPP_PP_DEF_IMPL_IS_PAREN_1(REQUIRES) \ + CPP_PP_DEF_IMPL_0 \ + /**/ +#define CPP_PP_DEF_DECL_template(...) \ + template(__VA_ARGS__), \ + /**/ +#define CPP_PP_DEF_template(...) \ + template<__VA_ARGS__> \ + /**/ +#define CPP_PP_DEF_concept +#define CPP_PP_DEF_class +#define CPP_PP_DEF_typename +#define CPP_PP_DEF_int +#define CPP_PP_DEF_bool +#define CPP_PP_DEF_size_t +#define CPP_PP_DEF_unsigned +#define CPP_PP_AUX_template(...) \ + CPP_PP_CAT2( \ + CPP_PP_TPARAM_, \ + CPP_PP_COUNT(__VA_ARGS__))(__VA_ARGS__) \ + /**/ +#define CPP_PP_TPARAM_1(_1) \ + CPP_PP_CAT2(CPP_PP_DEF_, _1) +#define CPP_PP_TPARAM_2(_1, ...) \ + CPP_PP_CAT2(CPP_PP_DEF_, _1), CPP_PP_TPARAM_1(__VA_ARGS__) +#define CPP_PP_TPARAM_3(_1, ...) \ + CPP_PP_CAT2(CPP_PP_DEF_, _1), CPP_PP_TPARAM_2(__VA_ARGS__) +#define CPP_PP_TPARAM_4(_1, ...) \ + CPP_PP_CAT2(CPP_PP_DEF_, _1), CPP_PP_TPARAM_3(__VA_ARGS__) +#define CPP_PP_TPARAM_5(_1, ...) \ + CPP_PP_CAT2(CPP_PP_DEF_, _1), CPP_PP_TPARAM_4(__VA_ARGS__) + +#define CPP_PP_PROBE_EMPTY_PROBE_CPP_PP_PROBE_EMPTY \ + CPP_PP_PROBE(~) \ + +#define CPP_PP_PROBE_EMPTY() +#define CPP_PP_IS_NOT_EMPTY(...) \ + CPP_PP_CHECK(CPP_PP_CAT(CPP_PP_PROBE_EMPTY_PROBE_, \ + CPP_PP_PROBE_EMPTY __VA_ARGS__ ())) \ + /**/ + +//////////////////////////////////////////////////////////////////////////////// +// CPP_template +// Usage: +// CPP_template(typename A, typename B) +// (requires Concept1 && Concept2) +// void foo(A a, B b) +// {} +#if CPP_CXX_CONCEPTS +#define CPP_template(...) \ + template<__VA_ARGS__> CPP_PP_EXPAND \ + /**/ +#define CPP_template_def CPP_template \ + /**/ +#define CPP_member +#define CPP_ctor(TYPE) TYPE CPP_CTOR_IMPL_1_ +#define CPP_CTOR_IMPL_1_(...) \ + (__VA_ARGS__) CPP_PP_EXPAND \ + /**/ +#else +#define CPP_template \ + CPP_template_sfinae \ + /**/ +#define CPP_template_def CPP_template_def_sfinae \ + /**/ +#define CPP_member CPP_member_sfinae +#define CPP_ctor CPP_ctor_sfinae +#endif + +#define CPP_template_sfinae(...) \ + template<__VA_ARGS__ CPP_TEMPLATE_SFINAE_AUX_ \ + /**/ +#define CPP_TEMPLATE_SFINAE_AUX_(...) , \ + typename CPP_true_ = std::true_type, \ + std::enable_if_t< \ + CPP_FORCE_TO_BOOL( \ + CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, __VA_ARGS__) && CPP_true_{} \ + ), \ + int \ + > = 0> \ + /**/ +#define CPP_template_def_sfinae(...) \ + template<__VA_ARGS__ CPP_TEMPLATE_DEF_SFINAE_AUX_ \ + /**/ +#define CPP_TEMPLATE_DEF_SFINAE_AUX_(...) , \ + typename CPP_true_, \ + std::enable_if_t< \ + CPP_FORCE_TO_BOOL( \ + CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, __VA_ARGS__) && CPP_true_{} \ + ), \ + int \ + >> \ + /**/ +#define CPP_TEMPLATE_SFINAE_AUX_3_requires +#define CPP_member_sfinae \ + CPP_broken_friend_member \ + /**/ +#define CPP_ctor_sfinae(TYPE) TYPE CPP_CTOR_SFINAE_IMPL_1_ +#define CPP_CTOR_SFINAE_IMPL_1_(...) \ + (__VA_ARGS__ \ + CPP_PP_COMMA_IIF( \ + CPP_PP_NOT(CPP_PP_IS_NOT_EMPTY(__VA_ARGS__))) \ + CPP_CTOR_SFINAE_REQUIRES \ + /**/ +#define CPP_CTOR_SFINAE_PROBE_NOEXCEPT_noexcept \ + CPP_PP_PROBE(~) \ + /**/ +#define CPP_CTOR_SFINAE_MAKE_PROBE(FIRST,...) \ + CPP_PP_CAT(CPP_CTOR_SFINAE_PROBE_NOEXCEPT_, FIRST) \ + /**/ +#define CPP_CTOR_SFINAE_REQUIRES(...) \ + CPP_PP_CAT(CPP_CTOR_SFINAE_REQUIRES_, \ + CPP_PP_CHECK(CPP_CTOR_SFINAE_MAKE_PROBE(__VA_ARGS__,)))(__VA_ARGS__) \ + /**/ +// No noexcept-clause: +#define CPP_CTOR_SFINAE_REQUIRES_0(...) \ + std::enable_if_t< \ + CPP_FORCE_TO_BOOL( \ + CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, __VA_ARGS__) && \ + CPP_INSTANCE(CPP_true(::concepts::detail::xNil{})) \ + ), \ + ::concepts::detail::Nil \ + > = {}) \ + /**/ +// Yes noexcept-clause: +#define CPP_CTOR_SFINAE_REQUIRES_1(...) \ + std::enable_if_t< \ + CPP_FORCE_TO_BOOL( \ + CPP_PP_CAT(CPP_TEMPLATE_SFINAE_AUX_3_, \ + CPP_PP_CAT(CPP_CTOR_SFINAE_EAT_NOEXCEPT_, __VA_ARGS__) \ + ) && CPP_INSTANCE(CPP_true(::concepts::detail::xNil{})) \ + ), \ + ::concepts::detail::Nil \ + > = {}) \ + CPP_PP_EXPAND(CPP_PP_CAT(CPP_CTOR_SFINAE_SHOW_NOEXCEPT_, __VA_ARGS__))) \ + /**/ +#define CPP_CTOR_SFINAE_EAT_NOEXCEPT_noexcept(...) +#define CPP_CTOR_SFINAE_SHOW_NOEXCEPT_noexcept(...) \ + noexcept(__VA_ARGS__) CPP_PP_EAT CPP_PP_LPAREN \ + /**/ + +#ifdef CPP_DOXYGEN_INVOKED +#define CPP_broken_friend_ret(...) \ + __VA_ARGS__ CPP_PP_EXPAND \ + /**/ +#else +#define CPP_broken_friend_ret(...) \ + ::concepts::return_t< \ + __VA_ARGS__, \ + std::enable_if_t> \ + /**/ +#ifdef CPP_WORKAROUND_MSVC_779763 +#define CPP_broken_friend_member \ + template<::concepts::detail::CPP_true_t const &CPP_true = \ + ::concepts::detail::CPP_true_> \ + /**/ +#else // ^^^ workaround / no workaround vvv +#define CPP_broken_friend_member \ + template \ + /**/ +#endif // CPP_WORKAROUND_MSVC_779763 +#endif + +#if CPP_CXX_CONCEPTS +#define CPP_ret(...) \ + __VA_ARGS__ CPP_PP_EXPAND \ + /**/ +#else +#define CPP_ret \ + CPP_broken_friend_ret \ + /**/ +#endif + +//////////////////////////////////////////////////////////////////////////////// +// CPP_fun +#if CPP_CXX_CONCEPTS +#define CPP_FUN_IMPL_1_(...) \ + (__VA_ARGS__) \ + CPP_PP_EXPAND \ + /**/ +#define CPP_fun(X) X CPP_FUN_IMPL_1_ +#else +#define CPP_FUN_IMPL_1_(...) \ + (__VA_ARGS__ \ + CPP_PP_COMMA_IIF( \ + CPP_PP_NOT(CPP_PP_IS_NOT_EMPTY(__VA_ARGS__))) \ + CPP_FUN_IMPL_REQUIRES \ + /**/ + +#define CPP_FUN_IMPL_REQUIRES(...) \ + CPP_FUN_IMPL_SELECT_CONST_(__VA_ARGS__,)(__VA_ARGS__) \ + /**/ + +#define CPP_FUN_IMPL_SELECT_CONST_(MAYBE_CONST, ...) \ + CPP_PP_CAT(CPP_FUN_IMPL_SELECT_CONST_, \ + CPP_PP_CHECK(CPP_PP_CAT( \ + CPP_PP_PROBE_CONST_PROBE_, MAYBE_CONST))) \ + /**/ + +#define CPP_PP_PROBE_CONST_PROBE_const CPP_PP_PROBE(~) + +#define CPP_FUN_IMPL_SELECT_CONST_1(...) \ + CPP_PP_EVAL( \ + CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_, \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_CONST_, __VA_ARGS__),)( \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_CONST_, __VA_ARGS__)) \ + /**/ + +#define CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_(MAYBE_NOEXCEPT, ...) \ + CPP_PP_CAT(CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_, \ + CPP_PP_CHECK(CPP_PP_CAT( \ + CPP_PP_PROBE_NOEXCEPT_PROBE_, MAYBE_NOEXCEPT))) \ + /**/ + +#define CPP_PP_PROBE_NOEXCEPT_PROBE_noexcept CPP_PP_PROBE(~) + +#define CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_0(...) \ + std::enable_if_t< \ + CPP_FORCE_TO_BOOL( \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_REQUIRES_, __VA_ARGS__) && \ + CPP_INSTANCE(CPP_true(::concepts::detail::xNil{})) \ + ), \ + ::concepts::detail::Nil \ + > = {}) const \ + /**/ + +#define CPP_FUN_IMPL_SELECT_CONST_NOEXCEPT_1(...) \ + std::enable_if_t< \ + CPP_FORCE_TO_BOOL( \ + CPP_PP_CAT( \ + CPP_FUN_IMPL_EAT_REQUIRES_, \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_NOEXCEPT_, __VA_ARGS__) \ + ) && CPP_INSTANCE(CPP_true(::concepts::detail::xNil{})) \ + ), \ + ::concepts::detail::Nil \ + > = {}) const \ + CPP_PP_EXPAND(CPP_PP_CAT(CPP_FUN_IMPL_SHOW_NOEXCEPT_, __VA_ARGS__))) \ + /**/ + +#define CPP_FUN_IMPL_EAT_NOEXCEPT_noexcept(...) +#define CPP_FUN_IMPL_SHOW_NOEXCEPT_noexcept(...) \ + noexcept(__VA_ARGS__) CPP_PP_EAT CPP_PP_LPAREN \ + /**/ + +#define CPP_FUN_IMPL_EAT_NOEXCEPT_noexcept(...) + +#define CPP_FUN_IMPL_EXPAND_NOEXCEPT_noexcept(...) \ + noexcept(__VA_ARGS__) \ + /**/ + +#define CPP_FUN_IMPL_SELECT_CONST_0(...) \ + CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_(__VA_ARGS__,)(__VA_ARGS__) \ + /**/ + +#define CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_(MAYBE_NOEXCEPT, ...) \ + CPP_PP_CAT(CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_, \ + CPP_PP_CHECK(CPP_PP_CAT( \ + CPP_PP_PROBE_NOEXCEPT_PROBE_, MAYBE_NOEXCEPT))) \ + /**/ + +#define CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_0(...) \ + std::enable_if_t< \ + CPP_FORCE_TO_BOOL( \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_REQUIRES_, __VA_ARGS__) && \ + CPP_INSTANCE(CPP_true(::concepts::detail::xNil{})) \ + ), \ + ::concepts::detail::Nil \ + > = {}) \ + /**/ + +#define CPP_FUN_IMPL_SELECT_NONCONST_NOEXCEPT_1(...) \ + std::enable_if_t< \ + CPP_FORCE_TO_BOOL( \ + CPP_PP_CAT( \ + CPP_FUN_IMPL_EAT_REQUIRES_, \ + CPP_PP_CAT(CPP_FUN_IMPL_EAT_NOEXCEPT_, __VA_ARGS__) \ + ) && \ + CPP_INSTANCE(CPP_true(::concepts::detail::xNil{})) \ + ), \ + ::concepts::detail::Nil \ + > = {}) \ + CPP_PP_EXPAND(CPP_PP_CAT(CPP_FUN_IMPL_SHOW_NOEXCEPT_, __VA_ARGS__))) \ + /**/ + +#define CPP_FUN_IMPL_EAT_CONST_const +#define CPP_FUN_IMPL_EAT_REQUIRES_requires + +//////////////////////////////////////////////////////////////////////////////// +// CPP_fun +// Usage: +// template +// void CPP_fun(foo)(A a, B b)([const]opt [noexcept(true)]opt +// requires Concept1 && Concept2) +// {} +// +// Note: This macro cannot be used when the last function argument is a +// parameter pack. +#define CPP_fun(X) X CPP_FUN_IMPL_1_ +#endif + +//////////////////////////////////////////////////////////////////////////////// +// CPP_auto_fun +// Usage: +// template +// auto CPP_auto_fun(foo)(A a, B b)([const]opt [noexcept(true)]opt)opt +// ( +// return a + b +// ) +#define CPP_auto_fun(X) X CPP_AUTO_FUN_IMPL_ +#define CPP_AUTO_FUN_IMPL_(...) (__VA_ARGS__) CPP_AUTO_FUN_RETURNS_ +#define CPP_AUTO_FUN_RETURNS_(...) \ + CPP_AUTO_FUN_SELECT_RETURNS_(__VA_ARGS__,)(__VA_ARGS__) \ + /**/ +#define CPP_AUTO_FUN_SELECT_RETURNS_(MAYBE_CONST, ...) \ + CPP_PP_CAT(CPP_AUTO_FUN_RETURNS_CONST_, \ + CPP_PP_CHECK(CPP_PP_CAT( \ + CPP_PP_PROBE_CONST_MUTABLE_PROBE_, MAYBE_CONST))) \ + /**/ +#define CPP_PP_PROBE_CONST_MUTABLE_PROBE_const CPP_PP_PROBE_N(~, 1) +#define CPP_PP_PROBE_CONST_MUTABLE_PROBE_mutable CPP_PP_PROBE_N(~, 2) +#define CPP_PP_EAT_MUTABLE_mutable +#define CPP_AUTO_FUN_RETURNS_CONST_2(...) \ + CPP_PP_CAT(CPP_PP_EAT_MUTABLE_, __VA_ARGS__) CPP_AUTO_FUN_RETURNS_CONST_0 +#define CPP_AUTO_FUN_RETURNS_CONST_1(...) \ + __VA_ARGS__ CPP_AUTO_FUN_RETURNS_CONST_0 \ + /**/ +#define CPP_AUTO_FUN_RETURNS_CONST_0(...) \ + CPP_PP_EVAL(CPP_AUTO_FUN_DECLTYPE_NOEXCEPT_, \ + CPP_PP_CAT(CPP_AUTO_FUN_RETURNS_, __VA_ARGS__)) \ + /**/ +#define CPP_AUTO_FUN_RETURNS_return + +#ifdef __cpp_guaranteed_copy_elision +#define CPP_AUTO_FUN_DECLTYPE_NOEXCEPT_(...) \ + noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \ + { return (__VA_ARGS__); } \ + /**/ +#else +#define CPP_AUTO_FUN_DECLTYPE_NOEXCEPT_(...) \ + noexcept(noexcept(decltype(__VA_ARGS__)(__VA_ARGS__))) -> \ + decltype(__VA_ARGS__) \ + { return (__VA_ARGS__); } \ + /**/ +#endif + +namespace concepts +{ + template + using bool_ = std::integral_constant; + +#if defined(__cpp_fold_expressions) && __cpp_fold_expressions >= 201603 + template + CPP_INLINE_VAR constexpr bool and_v = (Bs &&...); + + template + CPP_INLINE_VAR constexpr bool or_v = (Bs ||...); +#else + namespace detail + { + template + struct bools; + } // namespace detail + + template + CPP_INLINE_VAR constexpr bool and_v = + META_IS_SAME(detail::bools, detail::bools); + + template + CPP_INLINE_VAR constexpr bool or_v = + !META_IS_SAME(detail::bools, detail::bools); +#endif + + template + struct return_t_ + { + template + using invoke = T; + }; + + template + using return_t = meta::invoke, T>; + + namespace detail + { + template + CPP_INLINE_VAR constexpr T instance_ = T{}; + + template + constexpr bool requires_() + { + return true; + } + + struct boolean + { + friend bool operator&&(boolean, bool) = delete; + friend bool operator&&(bool, boolean) = delete; + friend bool operator||(boolean, bool) = delete; + friend bool operator||(bool, boolean) = delete; + }; + template + struct and_; + template + struct or_; + template + struct not_ : boolean + { + constexpr operator bool() const noexcept + { + return !(bool) T{}; + } + constexpr T operator!() const noexcept + { + return T{}; + } + template + constexpr and_ operator&&(That) const noexcept + { + return {}; + } + template + constexpr or_ operator||(That) const noexcept + { + return {}; + } + }; + + template + struct and_ : boolean + { + static constexpr bool impl(std::false_type) noexcept + { + return false; + } + static constexpr bool impl(std::true_type) noexcept + { + return (bool) U{}; + } + constexpr operator bool() const noexcept + { + return and_::impl(bool_<(bool) T{}>{}); + } + constexpr not_ operator!() const noexcept + { + return not_{}; + } + template + constexpr and_ operator&&(That) const noexcept + { + static_assert( + !META_IS_SAME(That, bool), + "All expressions in a conjunction should be " + "defer:: concepts"); + return {}; + } + template + constexpr or_ operator||(That) const noexcept + { + static_assert( + !META_IS_SAME(That, bool), + "All expressions in a disjunction should be " + "defer:: concepts"); + return {}; + } + }; + + template + struct or_ : boolean + { + static constexpr bool impl(std::true_type) noexcept + { + return true; + } + static constexpr bool impl(std::false_type) noexcept + { + return (bool) U{}; + } + constexpr operator bool() const noexcept + { + return or_::impl(bool_<(bool) T{}>{}); + } + constexpr not_ operator!() const noexcept + { + return {}; + } + template + constexpr detail::and_ operator&&(That) const noexcept + { + static_assert( + !META_IS_SAME(That, bool), + "All expressions in a disjunction should be " + "defer:: concepts"); + return {}; + } + template + constexpr detail::or_ operator||(That) const noexcept + { + static_assert( + !META_IS_SAME(That, bool), + "All expressions in a disjunction should be " + "defer:: concepts"); + return {}; + } + }; + + struct Nil + {}; + +#ifdef CPP_WORKAROUND_MSVC_779763 + enum class xNil {}; + + struct CPP_true_t + { + constexpr std::true_type operator()(Nil) const noexcept + { + return {}; + } + constexpr std::true_type operator()(xNil) const noexcept + { + return {}; + } + }; + + CPP_INLINE_VAR constexpr CPP_true_t CPP_true_{}; + + constexpr std::true_type CPP_true(xNil) + { + return {}; + } +#else + using xNil = Nil; +#endif + + constexpr std::true_type CPP_true(Nil) + { + return {}; + } + + template + using remove_cvref_t = + typename std::remove_cv::type>::type; + + CPP_def + ( + template(typename T, typename U) + concept weakly_equality_comparable_with_, + requires (detail::as_cref_t t, detail::as_cref_t u) + ( + (t == u) ? 1 : 0, + (t != u) ? 1 : 0, + (u == t) ? 1 : 0, + (u != t) ? 1 : 0 + ) + ); + } // namespace detail + +#if defined(__clang__) || defined(_MSC_VER) + template + std::enable_if_t requires_() + {} +#else + template + CPP_INLINE_VAR constexpr std::enable_if_t requires_ = 0; +#endif + + inline namespace defs + { + //////////////////////////////////////////////////////////////////////////////////////// + // Utility concepts + //////////////////////////////////////////////////////////////////////////////////////// + + CPP_def + ( + template(bool B) + (concept is_true)(B), + B + ); + + CPP_def + ( + template(typename... Args) + (concept type)(Args...), + true + ); + + CPP_def + ( + template(class T, template class Trait, typename... Args) + (concept satisfies)(T, Trait, Args...), + static_cast(Trait::type::value) + ); + + //////////////////////////////////////////////////////////////////////////////////////// + // Core language concepts + //////////////////////////////////////////////////////////////////////////////////////// + + CPP_def + ( + template(typename A, typename B) + concept same_as, + META_IS_SAME(A, B) && META_IS_SAME(B, A) + ); + + /// \cond + CPP_def + ( + template(typename A, typename B) + concept not_same_as_, + (!same_as, detail::remove_cvref_t>) + ); + + // Workaround bug in the Standard Library: + // From cannot be an incomplete class type despite that + // is_convertible should be equivalent to is_convertible + // in such a case. + CPP_def + ( + template(typename From, typename To) + concept implicitly_convertible_to, + std::is_convertible::type, To>::value + ); + + CPP_def + ( + template(typename From, typename To) + concept explicitly_convertible_to, + requires (From (&from)()) + ( + static_cast(from()) + ) + ); + /// \endcond + + CPP_def + ( + template(typename From, typename To) + concept convertible_to, + implicitly_convertible_to && + explicitly_convertible_to + ); + + CPP_def + ( + template(typename T, typename U) + concept derived_from, + META_IS_BASE_OF(U, T) && + convertible_to + ); + + CPP_def + ( + template(typename T, typename U) + concept common_reference_with, + same_as, common_reference_t> && + convertible_to> && + convertible_to> + ); + + CPP_def + ( + template(typename T, typename U) + concept common_with, + same_as, common_type_t> && + convertible_to> && + convertible_to> && + common_reference_with< + typename std::add_lvalue_reference::type, + typename std::add_lvalue_reference::type> && + common_reference_with< + typename std::add_lvalue_reference>::type, + common_reference_t< + typename std::add_lvalue_reference::type, + typename std::add_lvalue_reference::type>> + ); + + CPP_def + ( + template(typename T) + concept integral, + std::is_integral::value + ); + + CPP_def + ( + template(typename T) + concept signed_integral, + integral && + std::is_signed::value + ); + + CPP_def + ( + template(typename T) + concept unsigned_integral, + integral && + !signed_integral + ); + + CPP_def + ( + template(typename T, typename U) + concept assignable_from, + requires (T t, U &&u) + ( + t = (U &&) u, + requires_> + ) && + std::is_lvalue_reference::value + ); + + CPP_def + ( + template(typename T) + concept swappable, + requires (T &t, T &u) + ( + concepts::swap(t, u) + ) + ); + + CPP_def + ( + template(typename T, typename U) + concept swappable_with, + requires (T &&t, U &&u) + ( + concepts::swap((T &&) t, (T &&) t), + concepts::swap((U &&) u, (U &&) u), + concepts::swap((U &&) u, (T &&) t), + concepts::swap((T &&) t, (U &&) u) + ) && + common_reference_with, detail::as_cref_t> + ); + + //////////////////////////////////////////////////////////////////////////////////////////// + // Comparison concepts + //////////////////////////////////////////////////////////////////////////////////////////// + + CPP_def + ( + template(typename T) + concept equality_comparable, + detail::weakly_equality_comparable_with_ + ); + + CPP_def + ( + template(typename T, typename U) + concept equality_comparable_with, + equality_comparable && + equality_comparable && + detail::weakly_equality_comparable_with_ && + common_reference_with, detail::as_cref_t> && + equality_comparable< + common_reference_t, detail::as_cref_t>> + ); + + CPP_def + ( + template(typename T) + concept totally_ordered, + requires (detail::as_cref_t t, detail::as_cref_t u) + ( + t < u ? 1 : 0, + t > u ? 1 : 0, + u <= t ? 1 : 0, + u >= t ? 1 : 0 + ) && + equality_comparable + ); + + CPP_def + ( + template(typename T, typename U) + concept totally_ordered_with, + requires (detail::as_cref_t t, detail::as_cref_t u) + ( + t < u ? 1 : 0, + t > u ? 1 : 0, + t <= u ? 1 : 0, + t >= u ? 1 : 0, + u < t ? 1 : 0, + u > t ? 1 : 0, + u <= t ? 1 : 0, + u >= t ? 1 : 0 + ) && + totally_ordered && + totally_ordered && + equality_comparable_with && + common_reference_with, detail::as_cref_t> && + totally_ordered< + common_reference_t, detail::as_cref_t>> + ); + + //////////////////////////////////////////////////////////////////////////////////////////// + // Object concepts + //////////////////////////////////////////////////////////////////////////////////////////// + + CPP_def + ( + template(typename T) + concept destructible, + std::is_nothrow_destructible::value + ); + + CPP_def + ( + template(typename T, typename... Args) + (concept constructible_from)(T, Args...), + destructible && + META_IS_CONSTRUCTIBLE(T, Args...) + ); + + CPP_def + ( + template(typename T) + concept default_constructible, + constructible_from + ); + + CPP_def + ( + template(typename T) + concept move_constructible, + constructible_from && + convertible_to + ); + + CPP_def + ( + template(typename T) + concept copy_constructible, + move_constructible && + constructible_from && + constructible_from && + constructible_from && + convertible_to && + convertible_to && + convertible_to + ); + + CPP_def + ( + template(typename T) + concept movable, + std::is_object::value && + move_constructible && + assignable_from && + swappable + ); + + CPP_def + ( + template(typename T) + concept copyable, + copy_constructible && + movable && + assignable_from + ); + + CPP_def + ( + template(typename T) + concept semiregular, + copyable && + default_constructible + // Axiom: copies are independent. See Fundamentals of Generic Programming + // http://www.stepanovpapers.com/DeSt98.pdf + ); + + CPP_def + ( + template(typename T) + concept regular, + semiregular && + equality_comparable + ); + } // inline namespace defs +} // namespace concepts + +CPP_PP_IGNORE_CXX2A_COMPAT_END + +#endif // RANGES_V3_UTILITY_CONCEPTS_HPP diff --git a/inst/include/concepts/swap.hpp b/inst/include/concepts/swap.hpp new file mode 100644 index 0000000..ae99faa --- /dev/null +++ b/inst/include/concepts/swap.hpp @@ -0,0 +1,326 @@ +/// \file +// Concepts library +// +// Copyright Eric Niebler 2013-present +// +// Use, modification and distribution is subject to the +// Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Project home: https://github.com/ericniebler/range-v3 + +#ifndef CPP_SWAP_HPP +#define CPP_SWAP_HPP + +#include +#include +#include +#include + +// Note: constexpr implies inline, to retain the same visibility +// C++14 constexpr functions are inline in C++11 +#if (defined(__cpp_constexpr) && __cpp_constexpr >= 201304L) ||\ + (!defined(__cpp_constexpr) && __cplusplus >= 201402L) +#define CPP_CXX14_CONSTEXPR constexpr +#else +#define CPP_CXX14_CONSTEXPR inline +#endif + +#ifndef CPP_CXX_INLINE_VARIABLES +#ifdef __cpp_inline_variables // TODO: fix this if SD-6 picks another name +#define CPP_CXX_INLINE_VARIABLES __cpp_inline_variables +// TODO: remove once clang defines __cpp_inline_variables (or equivalent) +#elif defined(__clang__) && \ + (__clang_major__ > 3 || __clang_major__ == 3 && __clang_minor__ == 9) && \ + __cplusplus > 201402L +#define CPP_CXX_INLINE_VARIABLES 201606L +#else +#define CPP_CXX_INLINE_VARIABLES __cplusplus +#endif // __cpp_inline_variables +#endif // CPP_CXX_INLINE_VARIABLES + +#if defined(_MSC_VER) && !defined(__clang__) +#define CPP_WORKAROUND_MSVC_895622 // Error when phase 1 name binding finds only deleted function +#endif + +#if CPP_CXX_INLINE_VARIABLES < 201606L +#define CPP_INLINE_VAR +#define CPP_INLINE_VARIABLE(type, name) \ + inline namespace \ + { \ + constexpr auto &name = ::concepts::detail::static_const::value; \ + } \ + /**/ +#else // CPP_CXX_INLINE_VARIABLES >= 201606L +#define CPP_INLINE_VAR inline +#define CPP_INLINE_VARIABLE(type, name) \ + inline constexpr type name{}; \ + /**/ +#endif // CPP_CXX_INLINE_VARIABLES + +#if CPP_CXX_INLINE_VARIABLES < 201606L +#define CPP_DEFINE_CPO(type, name) \ + inline namespace \ + { \ + constexpr auto &name = ::concepts::detail::static_const::value; \ + } \ + /**/ +#else // CPP_CXX_INLINE_VARIABLES >= 201606L +#define CPP_DEFINE_CPO(type, name) \ + inline namespace _ \ + { \ + inline constexpr type name{}; \ + } \ + /**/ +#endif // CPP_CXX_INLINE_VARIABLES + +#if defined(_MSC_VER) && !defined(__clang__) +#define CPP_DIAGNOSTIC_IGNORE_INIT_LIST_LIFETIME +#else // ^^^ defined(_MSC_VER) ^^^ / vvv !defined(_MSC_VER) vvv +#if defined(__GNUC__) || defined(__clang__) +#define CPP_PRAGMA(X) _Pragma(#X) +#define CPP_DIAGNOSTIC_IGNORE_PRAGMAS \ + CPP_PRAGMA(GCC diagnostic ignored "-Wpragmas") +#define CPP_DIAGNOSTIC_IGNORE(X) \ + CPP_DIAGNOSTIC_IGNORE_PRAGMAS \ + CPP_PRAGMA(GCC diagnostic ignored "-Wunknown-pragmas") \ + CPP_PRAGMA(GCC diagnostic ignored X) +#define CPP_DIAGNOSTIC_IGNORE_INIT_LIST_LIFETIME \ + CPP_DIAGNOSTIC_IGNORE("-Wunknown-warning-option") \ + CPP_DIAGNOSTIC_IGNORE("-Winit-list-lifetime") +#else +#define CPP_DIAGNOSTIC_IGNORE_INIT_LIST_LIFETIME +#endif +#endif // MSVC/Generic configuration switch + +namespace concepts +{ + /// \cond + namespace detail + { + template + CPP_INLINE_VAR constexpr bool is_movable_v = + std::is_object::value && + std::is_move_constructible::value && + std::is_move_assignable::value; + + template + struct static_const + { + static constexpr T const value {}; + }; + template + constexpr T const static_const::value; + } + /// \endcond + + template + struct is_swappable; + + template + struct is_nothrow_swappable; + + template + struct is_swappable_with; + + template + struct is_nothrow_swappable_with; + + template + CPP_CXX14_CONSTEXPR + meta::if_c< + std::is_move_constructible::value && + std::is_assignable::value, T> + exchange(T &t, U &&u) + noexcept( + std::is_nothrow_move_constructible::value && + std::is_nothrow_assignable::value) + { + T tmp((T &&) t); + t = (U &&) u; + CPP_DIAGNOSTIC_IGNORE_INIT_LIST_LIFETIME + return tmp; + } + + /// \cond + namespace adl_swap_detail + { + struct nope + {}; + + // Intentionally create an ambiguity with std::swap, which is + // (possibly) unconstrained. + template + nope swap(T &, T &) = delete; + + template + nope swap(T (&)[N], T (&)[N]) = delete; + +#ifdef CPP_WORKAROUND_MSVC_895622 + nope swap(); +#endif + + template + decltype(swap(std::declval(), std::declval())) try_adl_swap_(int); + + template + nope try_adl_swap_(long); + + template + CPP_INLINE_VAR constexpr bool is_adl_swappable_v = + !META_IS_SAME(decltype(adl_swap_detail::try_adl_swap_(42)), nope); + + struct swap_fn + { + // Dispatch to user-defined swap found via ADL: + template + CPP_CXX14_CONSTEXPR + meta::if_c> + operator()(T &&t, U &&u) const + noexcept(noexcept(swap((T &&) t, (U &&) u))) + { + swap((T &&) t, (U &&) u); + } + + // For intrinsically swappable (i.e., movable) types for which + // a swap overload cannot be found via ADL, swap by moving. + template + CPP_CXX14_CONSTEXPR + meta::if_c< + !is_adl_swappable_v && + detail::is_movable_v> + operator()(T &a, T &b) const + noexcept(noexcept(b = concepts::exchange(a, (T &&) b))) + { + b = concepts::exchange(a, (T &&) b); + } + + // For arrays of intrinsically swappable (i.e., movable) types + // for which a swap overload cannot be found via ADL, swap array + // elements by moving. + template + CPP_CXX14_CONSTEXPR + meta::if_c< + !is_adl_swappable_v && + is_swappable_with::value> + operator()(T (&t)[N], U (&u)[N]) const + noexcept(is_nothrow_swappable_with::value) + { + for(std::size_t i = 0; i < N; ++i) + (*this)(t[i], u[i]); + } + + // For rvalue pairs and tuples of swappable types, swap the + // members. This permits code like: + // ranges::swap(std::tie(a,b,c), std::tie(d,e,f)); + template + CPP_CXX14_CONSTEXPR + meta::if_c::value && is_swappable_with::value> + operator()(std::pair &&left, std::pair &&right) const + noexcept( + is_nothrow_swappable_with::value && + is_nothrow_swappable_with::value) + { + swap_fn()(static_cast &&>(left).first, + static_cast &&>(right).first); + swap_fn()(static_cast &&>(left).second, + static_cast &&>(right).second); + } + + template + CPP_CXX14_CONSTEXPR + meta::if_c::value...>::value> + operator()(std::tuple &&left, std::tuple &&right) const + noexcept(meta::and_c::value...>::value) + { + swap_fn::impl( + static_cast &&>(left), + static_cast &&>(right), + meta::make_index_sequence{}); + } + + private: + template + static constexpr int ignore_unused(Ts &&...) + { + return 0; + } + template + CPP_CXX14_CONSTEXPR + static void impl(T &&left, U &&right, meta::index_sequence) + { + (void) swap_fn::ignore_unused( + (swap_fn()(std::get(static_cast(left)), + std::get(static_cast(right))), 42)...); + } + }; + + template + struct is_swappable_with_ + : std::false_type + {}; + + template + struct is_swappable_with_(), std::declval())), + decltype(swap_fn()(std::declval(), std::declval()))>> + : std::true_type + {}; + + template + struct is_nothrow_swappable_with_ + : meta::bool_(), std::declval())) && + noexcept(swap_fn()(std::declval(), std::declval()))> + {}; + + // Q: Should std::reference_wrapper be considered a proxy wrt swapping rvalues? + // A: No. Its operator= is currently defined to reseat the references, so + // std::swap(ra, rb) already means something when ra and rb are (lvalue) + // reference_wrappers. That reseats the reference wrappers but leaves the + // referents unmodified. Treating rvalue reference_wrappers differently would + // be confusing. + + // Q: Then why is it OK to "re"-define swap for pairs and tuples of references? + // A: Because as defined above, swapping an rvalue tuple of references has the same + // semantics as swapping an lvalue tuple of references. Rather than reseat the + // references, assignment happens *through* the references. + + // Q: But I have an iterator whose operator* returns an rvalue + // std::reference_wrapper. How do I make it model indirectly_swappable? + // A: With an overload of iter_swap. + } + /// \endcond + + /// \ingroup group-utility + template + struct is_swappable_with + : adl_swap_detail::is_swappable_with_ + {}; + + /// \ingroup group-utility + template + struct is_nothrow_swappable_with + : meta::and_< + is_swappable_with, + adl_swap_detail::is_nothrow_swappable_with_> + {}; + + /// \ingroup group-utility + template + struct is_swappable + : is_swappable_with + {}; + + /// \ingroup group-utility + template + struct is_nothrow_swappable + : is_nothrow_swappable_with + {}; + + /// \ingroup group-utility + /// \relates adl_swap_detail::swap_fn + CPP_DEFINE_CPO(adl_swap_detail::swap_fn, swap) +} + +#endif diff --git a/inst/include/concepts/type_traits.hpp b/inst/include/concepts/type_traits.hpp new file mode 100644 index 0000000..f8ee95c --- /dev/null +++ b/inst/include/concepts/type_traits.hpp @@ -0,0 +1,379 @@ +/// \file +// Concepts library +// +// Copyright Eric Niebler 2013-present +// +// Use, modification and distribution is subject to the +// Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Project home: https://github.com/ericniebler/range-v3 + +#ifndef CPP_TYPE_TRAITS_HPP +#define CPP_TYPE_TRAITS_HPP + +#include +#include +#include +#include + +namespace concepts +{ + template + using remove_cvref_t = + typename std::remove_cv< + typename std::remove_reference::type>::type; + + /// \cond + namespace detail + { + template + using is_convertible = std::is_convertible>, To>; + + template + struct if_else_ + { + template + using invoke = U; + }; + template<> + struct if_else_ + { + template + using invoke = T; + }; + template + using if_else_t = meta::invoke, T, U>; + + template + struct if_ + {}; + template<> + struct if_ + { + template + using invoke = T; + }; + template + using if_t = meta::invoke, T>; + + template + struct _copy_cv_ + { + using type = To; + }; + template + struct _copy_cv_ + { + using type = To const; + }; + template + struct _copy_cv_ + { + using type = To volatile; + }; + template + struct _copy_cv_ + { + using type = To const volatile; + }; + template + using _copy_cv = meta::_t<_copy_cv_>; + + //////////////////////////////////////////////////////////////////////////////////////// + template + struct _builtin_common; + + template + using _builtin_common_t = meta::_t<_builtin_common>; + + template + using _cond_res = decltype(true ? std::declval() : std::declval()); + + template> + using _rref_res = + if_else_t::value, meta::_t> &&, R>; + + template + using _lref_res = _cond_res<_copy_cv &, _copy_cv &>; + + template + struct as_cref_ + { + using type = T const &; + }; + template + struct as_cref_ + { + using type = T const &; + }; + template + struct as_cref_ + { + using type = T const &; + }; + template<> + struct as_cref_ + { + using type = void; + }; + template<> + struct as_cref_ + { + using type = void const; + }; + + template + using as_cref_t = typename as_cref_::type; + + template + using decay_t = typename std::decay::type; + + #if !defined(__GNUC__) || defined(__clang__) + template + struct _builtin_common_3 + {}; + template + struct _builtin_common_3, as_cref_t>>> + : std::decay<_cond_res, as_cref_t>> + {}; + template + struct _builtin_common_2 + : _builtin_common_3 + {}; + template + struct _builtin_common_2>> + : std::decay<_cond_res> + {}; + template + struct _builtin_common + : _builtin_common_2 + {}; + template + struct _builtin_common>::value && + is_convertible>::value>> + { + using type = _rref_res; + }; + template + struct _builtin_common + : meta::defer<_lref_res, T, U> + {}; + template + struct _builtin_common>::value>> + : _builtin_common + {}; + template + struct _builtin_common + : _builtin_common + {}; + #else + template + struct _builtin_common_3 + {}; + template + struct _builtin_common_3, as_cref_t>>> + : std::decay<_cond_res, as_cref_t>> + {}; + template + struct _builtin_common_2 + : _builtin_common_3 + {}; + template + struct _builtin_common_2>> + : std::decay<_cond_res> + {}; + template + struct _builtin_common + : _builtin_common_2 + {}; + template + struct _builtin_common_rr + : _builtin_common_2 + {}; + template + struct _builtin_common_rr>::value && + is_convertible>::value>> + { + using type = _rref_res; + }; + template + struct _builtin_common + : _builtin_common_rr + {}; + template + struct _builtin_common + : meta::defer<_lref_res, T, U> + {}; + template + struct _builtin_common_lr + : _builtin_common_2 + {}; + template + struct _builtin_common_lr>::value>> + : _builtin_common + {}; + template + struct _builtin_common + : _builtin_common_lr + {}; + template + struct _builtin_common + : _builtin_common + {}; + #endif + } + /// \endcond + + /// \addtogroup group-utility Utility + /// @{ + /// + + /// Users should specialize this to hook the \c common_with concept + /// until \c std gets a SFINAE-friendly \c std::common_type and there's + /// some sane way to deal with cv and ref qualifiers. + template + struct common_type + {}; + + template + struct common_type + : std::decay + {}; + + template + struct common_type + : detail::if_else_t< + (META_IS_SAME(detail::decay_t, T) && + META_IS_SAME(detail::decay_t, U) ), + meta::defer, + common_type, detail::decay_t>> + {}; + + template + using common_type_t = typename common_type::type; + + template + struct common_type + : meta::lazy::fold, T, meta::quote> + {}; + + /// @} + + /// \addtogroup group-utility Utility + /// @{ + /// + + /// Users can specialize this to hook the \c common_reference_with concept. + /// \sa `common_reference` + template< + typename T, + typename U, + template class TQual, + template class UQual> + struct basic_common_reference + {}; + + /// \cond + namespace detail + { + using _rref = + meta::quote_trait; + using _lref = + meta::quote_trait; + + template + struct _xref + { + template + using invoke = T; + }; + template + struct _xref + { + template + using invoke = + meta::_t, U>>>; + }; + template + struct _xref + { + template + using invoke = + meta::_t, U>>>; + }; + template + struct _xref + { + template + using invoke = U const; + }; + template + struct _xref + { + template + using invoke = U volatile; + }; + template + struct _xref + { + template + using invoke = U const volatile; + }; + + template + using _basic_common_reference = + basic_common_reference< + remove_cvref_t, + remove_cvref_t, + _xref::template invoke, + _xref::template invoke>; + + template + struct _common_reference2 + : if_else_t< + meta::is_trait<_basic_common_reference>::value, + _basic_common_reference, + common_type> + {}; + + template + struct _common_reference2>::value>> + : _builtin_common + {}; + } + /// \endcond + + /// Users can specialize this to hook the \c common_reference_with concept. + /// \sa `basic_common_reference` + template + struct common_reference + {}; + + template + struct common_reference + { + using type = T; + }; + + template + struct common_reference + : detail::_common_reference2 + {}; + + template + using common_reference_t = typename common_reference::type; + + template + struct common_reference + : meta::lazy::fold, T, meta::quote> + {}; + /// @} +} // namespace concepts + +#endif diff --git a/inst/include/eigenh5/MatSlices.hpp b/inst/include/eigenh5/MatSlices.hpp index e7fef72..4acc96a 100644 --- a/inst/include/eigenh5/MatSlices.hpp +++ b/inst/include/eigenh5/MatSlices.hpp @@ -7,7 +7,7 @@ #include - +#define EIGEN_RUNTIME_NO_MALLOC // template // class DataHandle{ @@ -26,6 +26,8 @@ class DataQueue{ public: std::vector< DatasetSelection > selections; private: + + // Eigen::Matrix data_buffer; FileManager &f_map; std::unordered_map > dataset_map; std::vector file_selections; @@ -47,6 +49,7 @@ class DataQueue{ f_map(f_map_){ selections.reserve(num_selections); file_selections.reserve(num_selections); + // size_t max_dims=0; for(int i=0; i(options(i),"filename"); auto dn = get_list_scalar(options(i),"datapath"); @@ -55,11 +58,17 @@ class DataQueue{ } auto td = get_dataset(*fn,*dn); std::vector tdims = td->getDataDimensions(); - std::array a_dims; - std::copy_n(tdims.begin(),Dims,a_dims.begin()); - selections.push_back(DatasetSelection::ProcessList(options(i),a_dims)); - file_selections.push_back(*fn+*dn); + std::array a_dims; + std::copy_n(tdims.begin(), Dims, a_dims.begin()); + selections.push_back( + DatasetSelection::ProcessList(options(i), a_dims)); + // size_t tsize_dim = std::accumulate(dsl.dataset_dimensions.begin(),dsl.dataset_dimensions.end(),1,std::multiplies()); + // if (tsize_dim > max_dims) { + // max_dims = tsize_dim; + // } + file_selections.push_back(*fn + *dn); } + // data_buffer.resize(max_dims); } std::vector > get_selection_dims() const{ std::vector > retvec(num_selections); @@ -91,12 +100,32 @@ class DataQueue{ auto n_elem = file_sel.getDataDimensions(); const size_t elem_total= std::accumulate(n_elem.begin(),n_elem.end(),1,std::multiplies()); datamat.resize(n_elem[0],n_elem[1]); + Eigen::Map > retd(datamat.data(),n_elem[0],n_elem[1]); data_sel.readEigen(file_sel,retd); if(doTranspose){ datamat.transposeInPlace(); } } + // template + // Eigen::Map >readMat(const size_t i,bool doTranspose=false){ + // + // auto data_r = get_index(i); + // auto &dataset = data_r.first; + // auto &data_sel = data_r.second; + // + // auto file_sel = data_sel.makeSelection(*dataset); + // auto n_elem = file_sel.getDataDimensions(); + // const size_t elem_total= std::accumulate(n_elem.begin(),n_elem.end(),1,std::multiplies()); + // + // Eigen::Map > retd(data_buffer.data(),n_elem[0],n_elem[1]); + // data_sel.readEigen(file_sel,retd); + // if (doTranspose) { + // retd.transposeInPlace(); + // } + // return (retd); + // } + void readVector(const size_t i,Eigen::Matrix &datamat){ auto data_r = get_index(i); @@ -110,7 +139,23 @@ class DataQueue{ Eigen::Map > retd(datamat.data(),n_elem[0]); data_sel.readEigen(file_sel,retd); } - + + // Eigen::Map> readVector(const size_t i) { + // + // auto data_r = get_index(i); + // auto &dataset = data_r.first; + // auto &data_sel = data_r.second; + // + // auto file_sel = data_sel.makeSelection(*dataset); + // auto n_elem = file_sel.getDataDimensions(); + // const size_t elem_total = std::accumulate(n_elem.begin(), n_elem.end(), 1, + // std::multiplies()); + // Eigen::Map> retd(data_buffer.data(), + // n_elem[0]); + // data_sel.readEigen(file_sel, retd); + // return (retd); + // } + template void writeMat(const size_t i,Eigen::Matrix &retmat){ static_assert(isReadOnly ==false,"cannot write to a readOnly DataQueue!"); diff --git a/inst/include/eigenh5/Selection.hpp b/inst/include/eigenh5/Selection.hpp index 2161385..99d1c53 100644 --- a/inst/include/eigenh5/Selection.hpp +++ b/inst/include/eigenh5/Selection.hpp @@ -135,7 +135,10 @@ struct dim_sel{ }; inline std::vector dim_sel::parse_chunk_list(const Rcpp::List &list,std::vector datadims){ - using int_o = boost::optional; + using int_o = std::optional; + + + const size_t num_dims= datadims.size(); if(num_dims>2){ @@ -160,7 +163,7 @@ inline std::vector dim_sel::parse_chunk_list(const Rcpp::List &list,std - +//template subset); + std::optional subset); Eigen::ArrayXi permutation_order() const; @@ -218,8 +221,6 @@ class DimRange{ bool isCompact_; bool all_sorted; bool isRepeated_; - // static std::vector find_cont(Rcpp::IntegerVector::const_iterator itb,Rcpp::IntegerVector::const_iterator ite); - }; @@ -253,7 +254,7 @@ inline Eigen::ArrayXi DimRange::permutation_order() const { inline DimRange DimRange::construct_dimrange(dim_sel chunk, - boost::optional subset){ + std::optional subset){ if(subset){ return(DimRange(subset->begin(),subset->end())); } @@ -459,7 +460,6 @@ inline DatasetSelection DatasetSelection::ProcessList(const Rcpp::Li inline DimRange::DimRange(Rcpp::IntegerVector::const_iterator itb,Rcpp::IntegerVector::const_iterator ite){ using namespace Rcpp; - // using namespace ranges; using namespace boost; using namespace boost::icl; @@ -501,15 +501,16 @@ inline DimRange::DimRange(Rcpp::IntegerVector::const_iterator itb,Rcpp::IntegerV } } if(ins){ - if((t_it-itbb)!=abs((*t_it-*itbb))){ - Rcpp::stop("dim_sel is not compact!"); - } - dim_sel tds((*itbb)-1,*(t_it)-1,tot_dist,tot_dist+(t_it-itbb)); - in_sels.insert(construct >(tds.in_start,tds.in_stop,interval_bounds::closed())); - dim_sels.push_back(tds); - tot_dist=tot_dist+tds.chunksize; - itbb=nit; - t_it=nit; + if ((t_it - itbb) != abs((*t_it - *itbb))) { + Rcpp::stop("dim_sel is not compact!"); + } + dim_sel tds((*itbb) - 1, *(t_it)-1, tot_dist, tot_dist + (t_it - itbb)); + in_sels.insert(construct>( + tds.in_start, tds.in_stop, interval_bounds::closed())); + dim_sels.push_back(tds); + tot_dist = tot_dist + tds.chunksize; + itbb = nit; + t_it = nit; } } } @@ -527,45 +528,12 @@ inline DimRange::DimRange(Rcpp::IntegerVector::const_iterator itb,Rcpp::IntegerV Rcpp::Rcerr<<"size of space for it is :"< inline HighFive::Selection DatasetSelection::makeSelection(const HighFive::DataSet &dset) const{ if(offsets_in.empty()){ diff --git a/inst/include/eigenh5/indexers.hpp b/inst/include/eigenh5/indexers.hpp new file mode 100644 index 0000000..a1d61aa --- /dev/null +++ b/inst/include/eigenh5/indexers.hpp @@ -0,0 +1,623 @@ +#include +#include +#include +// [[Rcpp::interfaces(r, cpp)]] +//[[Rcpp::plugins(cpp17)]] +//#include +#include "highfive/H5DataSet.hpp" +#include "xtensor-r/rarray.hpp" +#include "xtensor-r/rtensor.hpp" +#include "xtensor-r/rvectorize.hpp" +#include "xtensor-r/rcontainer.hpp" +#include +#include +#include +#include +#include +#include +#include + +class Interval{ + size_t offset; + size_t size; +public: + Interval(int offset_,int size_):offset(offset_),size(size_){} + const size_t get_offset() const{return offset;} + const size_t get_size() const{return size;} +}; + + +class SubInterval{ + size_t offset; + size_t size; +public: + constexpr SubInterval(size_t offset_,int chunksize_): + offset(offset_), + size(std::max(chunksize_,0)){ + if(chunksize_<0){ + Rcpp::Rcerr< offset_chunksize): + offset(offset_chunksize.first), + size(std::max(offset_chunksize.second,0)){ + if(offset_chunksize.second<0){ + Rcpp::Rcerr< > offset_chunksize,size_t total_size_): + offset(offset_chunksize.first), + size(size=offset_chunksize.second.value_or(total_size_-offset)) + { + if(offset_chunksize.second.has_value() && offset_chunksize.second<0){ + Rcpp::stop("negative chunksize has been deprecated in SubInterval"); + } + if(offset+size > total_size_){ + Rcpp::Rcerr<<"offset_chunksize is: "<= total_size_){ + Rcpp::Rcerr<<"SubInterval is: "<=end ? size : y_end-offset+1); + } + if(y_end>end){ + return SubInterval(y.offset-offset,end-(y.offset-offset)+1); + } + return SubInterval(y.offset-offset, y.size); + } + + constexpr size_t get_offset() const noexcept{ + return offset; + } + constexpr size_t get_size() const noexcept{ + return size; + } + constexpr size_t get_back() const noexcept{ + return offset+size-1; + } + constexpr size_t num_chunks(const size_t chunksize)const noexcept{ + return 1 + ((size - 1) / chunksize); + } + friend class chunk_chunker; + + + // static std::vector make_chunked_selection( const SubInterval parent, const SubInterval selection,const size_t chunksize){ + + + + + + // // const size_t + + + // } + +}; + + + + +class rep_chunk_indexer{ + std::array offset_size; //Logical offset/size of chunk on disk + std::vector chunk_indexes; //indexes within chunk + std::vector out_indexes; //indexes in source/dest memory + using i_it= std::vector::const_iterator; +public: + rep_chunk_indexer(const std::array offset_size_): + offset_size(offset_size_), + chunk_indexes([](const size_t res_num){ + std::vector retv; + retv.reserve(res_num); + return(retv); + }(offset_size[1])), + out_indexes([](const size_t res_num){ + std::vector retv; + retv.reserve(res_num); + return(retv); + }(offset_size[1])){ + } + int push_back(const int index,const int i) noexcept + { + chunk_indexes.push_back(index-offset_size[0]); + out_indexes.push_back(i); + return out_indexes.size(); + } + size_t disk_offset()const noexcept{ + return offset_size[0]; + } + size_t disk_size()const noexcept{ + return offset_size[1]; + } + size_t chunk_size()const noexcept{ + return chunk_indexes.size(); + } + auto chunk_slice() const{ + return xt::keep(chunk_indexes); + } + + auto mem_slice() const{ + return xt::keep(out_indexes); + } + + int chunk_i(size_t i)const noexcept{ + return chunk_indexes[i]; + } + int mem_i(size_t i)const noexcept{ + return out_indexes[i]; + } +}; + + + + +class IndexParser{ +public: +private: + int p; + int dimsize; + int chunksize; + int num_chunks; + std::vector needed_chunks; + std::vector> tneeded_chunks; + + using chunk_it =std::vector::const_iterator; + int chunks_used; + bool is_unsorted; + using Iv=Rcpp::IntegerVector; + // const + size_t max_chunksize; + +public: + using chunk_type=rep_chunk_indexer; + IndexParser(const size_t dimsize_,const size_t chunksize_,const Iv input,bool whole_only=false): p(input.size()), + dimsize(dimsize_), + chunksize(chunksize_), + num_chunks(ceilf(static_cast(dimsize)/static_cast(chunksize))), + tneeded_chunks(num_chunks), + chunks_used(0), + is_unsorted(false), + max_chunksize(0) + { + + if(whole_only){ + Rcpp::stop("IndexParser not available when whole_only set to true"); + } + + // super easy to calculate which chunks we need + int i=0; + int oi=-1; + int ix=0; + for(auto inp: input){ + i=inp-1; + if(i<=oi){ + is_unsorted=true; + } + + int chunk_no = i/chunksize; + if(chunk_no>=tneeded_chunks.size()){ + // Rcpp::Rcerr<<"in index_dimension"<="<( + new rep_chunk_indexer({static_cast(chunk_no * chunksize), + static_cast(chunksize)})); + chunks_used++; + // shared_ptr TempEmp(new Employee()); + } + int tc = it_el->push_back(i,ix); + if(tc>max_chunksize){ + max_chunksize=tc; + } + oi=i; + ix++; + } + + + tneeded_chunks.erase(std::remove_if(tneeded_chunks.begin(),tneeded_chunks.end(),[](const auto& data_el){ + return(data_el==nullptr); + }),tneeded_chunks.end()); + if(tneeded_chunks.size()!=chunks_used){ + Rcpp::Rcerr<<"counted chunks is: "< sub_offset_size; // offset/size within chunk + size_t dest_d_offset; +public: + chunk_chunker(const SubInterval interval_, + const SubInterval &chunk_, + const size_t dest_offset_) + : global_interval(interval_), + relative_interval(global_interval.sub_chunk(chunk_)), + dest_d_offset(dest_offset_){ + } + + size_t chunk_size() const noexcept{ + return(relative_interval.size); + } + size_t chunk_offset() const noexcept{ + return(relative_interval.offset); + } + auto chunk_slice() const{ + return(xt::range(chunk_offset(),chunk_offset()+chunk_size())); + } + auto mem_slice() const{ + return(xt::range(dest_offset(),dest_offset()+dest_size())); + } + + size_t disk_offset() const noexcept{ + return global_interval.offset; + } + + size_t disk_size() const noexcept{ + return global_interval.size; + } + + size_t dest_offset() const noexcept{ + return dest_d_offset; + } + + size_t dest_size() const noexcept{ + return chunk_size(); + } + + int chunk_i(size_t i)const noexcept{ + return relative_interval.offset+i; + } + + int mem_i(size_t i)const noexcept{ + return dest_d_offset+i; + } +}; + + + +class ChunkParser{ +private: + int dimsize; + SubInterval selection; + int chunksize; + int p; + int chunks_used; + + std::vector needed_chunks; +public: + using chunk_it =std::vector::const_iterator; + using chunk_type=chunk_chunker; + ChunkParser(const size_t dimsize_,const size_t chunksize_,const std::pair> selection_p,const bool whole_only=false): + dimsize(dimsize_), + selection(selection_p,dimsize), + chunksize(chunksize_), + p(selection.get_size()) + { + const auto chunk_selection = SubInterval(0,dimsize).chunk_selection(selection,chunksize); + if(whole_only){ + if(chunk_selection.get_offset()!=selection.get_offset()){ + Rcpp::stop("chunk offset must be on a chunk boundary when whole_only set to true"); + } + if(selection.get_size()%chunksize!=0){ + Rcpp::stop("size of selection must be a multiple of chunksize when whole_only set to true"); + } + } + + chunks_used = chunk_selection.num_chunks(chunksize); + needed_chunks.reserve(chunks_used); + int out_o=0; + for(int i=0; i +struct t2chunk_t; + +template<> struct t2chunk_t> >{ + typedef ChunkParser c_type; +}; + + +template<> struct t2chunk_t{ + typedef IndexParser c_type; +}; + + +template +struct xtm_t; + +template<> +struct xtm_t{ + typedef xt::rtensor retvec_type; + typedef xt::rtensor retmat_type; + typedef xt::rtensor reta_type; + typedef xt::xtensor buffvec_type; + typedef xt::xtensor buffmat_type; + typedef xt::xtensor buffa_type; + typedef Rcpp::IntegerVector rrvec_type; + typedef Rcpp::IntegerMatrix rrmat_type; +}; + +template<> +struct xtm_t{ + typedef xt::rtensor retvec_type; + typedef xt::rtensor retmat_type; + typedef xt::rtensor reta_type; + typedef xt::xtensor buffvec_type; + typedef xt::xtensor buffmat_type; + typedef xt::xtensor buffa_type; + typedef Rcpp::NumericVector rrvec_type; + typedef Rcpp::NumericMatrix rrmat_type; +}; + + +template<> +struct xtm_t{ + typedef Rcpp::StringVector retvec_type; + typedef Rcpp::StringMatrix retmat_type; + typedef std::false_type reta_type; + typedef xt::xtensor buffvec_type; + typedef xt::xtensor buffmat_type; + + typedef std::false_type buffa_type; + typedef Rcpp::StringVector rrvec_type; + typedef Rcpp::StringMatrix rrmat_type; +}; + + + +template<> +struct xtm_t{ + typedef xt::rtensor retvec_type; + typedef xt::rtensor retmat_type; + typedef xt::rtensor reta_type; + typedef xt::xtensor buffvec_type; + typedef xt::xtensor buffmat_type; + typedef xt::xtensor buffa_type; + typedef Rcpp::RawVector rrvec_type; + typedef Rcpp::RawMatrix rrmat_type; +}; + + + + + +template +class DataSet_Context{ + +public: + const HighFive::DataSet& d; +private: + + using tensor_type=typename xtm_t::buffmat_type; + const size_t elem_size; + const std::vector dataset_chunksizes; + std::vector raw_chunk_buffer; +public: + DataSet_Context(const HighFive::DataSet& d_):d(d_),elem_size(d.getDataType().n_elem()),dataset_chunksizes(d.getFilter().get_chunksizes()){ + auto raw_size=std::accumulate(dataset_chunksizes.begin(),dataset_chunksizes.end(),sizeof(typename tensor_type::value_type)*elem_size,std::multiplies()); + raw_chunk_buffer.resize(raw_size); + } + + template + void write_dataset(const TA& tchunk_r, LC& lambda){ + auto res = lambda(tchunk_r,raw_chunk_buffer.data(),raw_chunk_buffer.size(),elem_size); + d.write_raw_chunk(raw_chunk_buffer,{tchunk_r.disk_offset()},res); + } + + template + void write_dataset(const TA& tchunk_r, const TB& tchunk_c, LC& lambda){ + auto res = lambda(tchunk_r,tchunk_c,raw_chunk_buffer.data(),raw_chunk_buffer.size(),elem_size); + d.write_raw_chunk(raw_chunk_buffer,{tchunk_r.disk_offset(),tchunk_c.disk_offset()},res); + } + + template + void write_dataset(const TA& tchunk_r, const TB& tchunk_c,const TC& tchunk_a, LC& lambda){ + auto res = lambda(tchunk_r,tchunk_c,tchunk_a,raw_chunk_buffer.data(),raw_chunk_buffer.size(),elem_size); + d.write_raw_chunk(raw_chunk_buffer,{tchunk_r.disk_offset(),tchunk_c.disk_offset(),tchunk_a.disk_offset()},res); + } + + + template + void read_dataset(const TA& tchunk_r, LC& lambda){ + auto res = d.read_raw_chunk(raw_chunk_buffer,{tchunk_r.disk_offset()}); + lambda(tchunk_r,raw_chunk_buffer.data(),res,elem_size); + } + + template + void read_dataset(const TA& tchunk_r, const TB& tchunk_c, LC& lambda){ + auto res = d.read_raw_chunk(raw_chunk_buffer,{tchunk_r.disk_offset(),tchunk_c.disk_offset()}); + lambda(tchunk_r,tchunk_c,raw_chunk_buffer.data(),res,elem_size); + + } + + template + void read_dataset(const TA& tchunk_r, const TB& tchunk_c,const TC& tchunk_a, LC& lambda){ + auto res = d.read_raw_chunk(raw_chunk_buffer,{tchunk_r.disk_offset(),tchunk_c.disk_offset(),tchunk_a.disk_offset()}); + lambda(tchunk_r,tchunk_c,tchunk_a,raw_chunk_buffer.data(),res,elem_size); + } + + + template + void iter_dataset_read(const RngA& RowChunksBegin,const RngA& RowChunksEnd,LC& lambda){ + for(auto &tchunk_r = RowChunksBegin; tchunk_r!=RowChunksEnd; ++tchunk_r){ + read_dataset(tchunk_r,lambda); + } + } + + template + void iter_dataset_read(const RngA& RowChunksBegin,const RngA& RowChunksEnd, const RngB& ColChunksBegin,const RngB& ColChunksEnd,LC& lambda){ + for(auto &tchunk_r = RowChunksBegin; tchunk_r!=RowChunksEnd; ++tchunk_r){ + for(auto &tchunk_c = ColChunksBegin; tchunk_c!=ColChunksEnd; ++tchunk_c){ + read_dataset(tchunk_r,tchunk_c,lambda); + } + } + } + + + + template + void iter_dataset_read(const RngA& RowChunksBegin,const RngA& RowChunksEnd, const RngB& ColChunksBegin,const RngB& ColChunksEnd,const RngC& AChunksBegin,const RngC& AChunksEnd,LC& lambda){ + for(auto &tchunk_r = RowChunksBegin; tchunk_r!=RowChunksEnd; ++tchunk_r){ + for(auto &tchunk_c = ColChunksBegin; tchunk_c!=ColChunksEnd; ++tchunk_c){ + for(auto &tchunk_a = AChunksBegin; tchunk_a!=AChunksEnd; ++tchunk_a){ + read_dataset(tchunk_r,tchunk_c,tchunk_a,lambda); + } + } + } + } + + template + void iter_dataset_write(const RngA& RowChunksBegin,const RngA& RowChunksEnd,LC& lambda){ + for(auto &tchunk_r = RowChunksBegin; tchunk_r!=RowChunksEnd; ++tchunk_r){ + write_dataset(tchunk_r,lambda); + } + } + + + template + void iter_dataset_write(const RngA& RowChunksBegin,const RngA& RowChunksEnd, const RngB& ColChunksBegin,const RngB& ColChunksEnd,LC& lambda){ + for(auto &tchunk_r = RowChunksBegin; tchunk_r!=RowChunksEnd; ++tchunk_r){ + for(auto &tchunk_c = ColChunksBegin; tchunk_c!=ColChunksEnd; ++tchunk_c){ + write_dataset(tchunk_r,tchunk_c,lambda); + } + } + } + + template + void iter_dataset_write(const RngA& RowChunksBegin,const RngA& RowChunksEnd, const RngB& ColChunksBegin,const RngB& ColChunksEnd,const RngC& AChunksBegin,const RngC& AChunksEnd,LC& lambda){ + for(auto &tchunk_r = RowChunksBegin; tchunk_r!=RowChunksEnd; ++tchunk_r){ + for(auto &tchunk_c = ColChunksBegin; tchunk_c!=ColChunksEnd; ++tchunk_c){ + for(auto &tchunk_a = AChunksBegin; tchunk_a!=AChunksEnd; ++tchunk_a){ + write_dataset(tchunk_r,tchunk_c,tchunk_a,lambda); + } + } + } + } + +}; diff --git a/inst/include/gsl/gsl b/inst/include/gsl/gsl deleted file mode 100644 index 55862eb..0000000 --- a/inst/include/gsl/gsl +++ /dev/null @@ -1,29 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GSL_GSL_H -#define GSL_GSL_H - -#include // copy -#include // Ensures/Expects -#include // byte -#include // finally()/narrow()/narrow_cast()... -#include // multi_span, strided_span... -#include // owner, not_null -#include // span -#include // zstring, string_span, zstring_builder... - -#endif // GSL_GSL_H diff --git a/inst/include/gsl/gsl_algorithm b/inst/include/gsl/gsl_algorithm deleted file mode 100644 index 710792f..0000000 --- a/inst/include/gsl/gsl_algorithm +++ /dev/null @@ -1,63 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GSL_ALGORITHM_H -#define GSL_ALGORITHM_H - -#include // for Expects -#include // for dynamic_extent, span - -#include // for copy_n -#include // for ptrdiff_t -#include // for is_assignable - -#ifdef _MSC_VER -#pragma warning(push) - -// turn off some warnings that are noisy about our Expects statements -#pragma warning(disable : 4127) // conditional expression is constant -#pragma warning(disable : 4996) // unsafe use of std::copy_n - -// blanket turn off warnings from CppCoreCheck for now -// so people aren't annoyed by them when running the tool. -// more targeted suppressions will be added in a future update to the GSL -#pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495) -#endif // _MSC_VER - -namespace gsl -{ - -template -void copy(span src, span dest) -{ - static_assert(std::is_assignable::value, - "Elements of source span can not be assigned to elements of destination span"); - static_assert(SrcExtent == dynamic_extent || DestExtent == dynamic_extent || - (SrcExtent <= DestExtent), - "Source range is longer than target range"); - - Expects(dest.size() >= src.size()); - std::copy_n(src.data(), src.size(), dest.data()); -} - -} // namespace gsl - -#ifdef _MSC_VER -#pragma warning(pop) -#endif // _MSC_VER - -#endif // GSL_ALGORITHM_H diff --git a/inst/include/gsl/gsl_assert b/inst/include/gsl/gsl_assert deleted file mode 100644 index 131fa8b..0000000 --- a/inst/include/gsl/gsl_assert +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GSL_CONTRACTS_H -#define GSL_CONTRACTS_H - -#include -#include // for logic_error - -// -// Temporary until MSVC STL supports no-exceptions mode. -// Currently terminate is a no-op in this mode, so we add termination behavior back -// -#if defined(_MSC_VER) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS -#define GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND -#endif - -// -// There are three configuration options for this GSL implementation's behavior -// when pre/post conditions on the GSL types are violated: -// -// 1. GSL_TERMINATE_ON_CONTRACT_VIOLATION: std::terminate will be called (default) -// 2. GSL_THROW_ON_CONTRACT_VIOLATION: a gsl::fail_fast exception will be thrown -// 3. GSL_UNENFORCED_ON_CONTRACT_VIOLATION: nothing happens -// -#if !(defined(GSL_THROW_ON_CONTRACT_VIOLATION) || defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) || \ - defined(GSL_UNENFORCED_ON_CONTRACT_VIOLATION)) -#define GSL_TERMINATE_ON_CONTRACT_VIOLATION -#endif - -#define GSL_STRINGIFY_DETAIL(x) #x -#define GSL_STRINGIFY(x) GSL_STRINGIFY_DETAIL(x) - -#if defined(__clang__) || defined(__GNUC__) -#define GSL_LIKELY(x) __builtin_expect(!!(x), 1) -#define GSL_UNLIKELY(x) __builtin_expect(!!(x), 0) -#else -#define GSL_LIKELY(x) (!!(x)) -#define GSL_UNLIKELY(x) (!!(x)) -#endif - -// -// GSL_ASSUME(cond) -// -// Tell the optimizer that the predicate cond must hold. It is unspecified -// whether or not cond is actually evaluated. -// -#ifdef _MSC_VER -#define GSL_ASSUME(cond) __assume(cond) -#elif defined(__GNUC__) -#define GSL_ASSUME(cond) ((cond) ? static_cast(0) : __builtin_unreachable()) -#else -#define GSL_ASSUME(cond) static_cast((cond) ? 0 : 0) -#endif - -// -// GSL.assert: assertions -// - -namespace gsl -{ -struct fail_fast : public std::logic_error -{ - explicit fail_fast(char const* const message) : std::logic_error(message) {} -}; - -namespace details -{ -#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) - - typedef void (__cdecl *terminate_handler)(); - - inline gsl::details::terminate_handler& get_terminate_handler() noexcept - { - static terminate_handler handler = &abort; - return handler; - } - -#endif - - [[noreturn]] inline void terminate() noexcept - { -#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) - (*gsl::details::get_terminate_handler())(); -#else - std::terminate(); -#endif - } - -#if defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) - - template - [[noreturn]] void throw_exception(Exception&&) - { - gsl::details::terminate(); - } - -#else - - template - [[noreturn]] void throw_exception(Exception&& exception) - { - throw std::forward(exception); - } - -#endif - -} // namespace details -} // namespace gsl - -#if defined(GSL_THROW_ON_CONTRACT_VIOLATION) - -#define GSL_CONTRACT_CHECK(type, cond) \ - (GSL_LIKELY(cond) ? static_cast(0) \ - : gsl::details::throw_exception(gsl::fail_fast( \ - "GSL: " type " failure at " __FILE__ ": " GSL_STRINGIFY(__LINE__)))) - -#elif defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) - -#define GSL_CONTRACT_CHECK(type, cond) \ - (GSL_LIKELY(cond) ? static_cast(0) : gsl::details::terminate()) - -#elif defined(GSL_UNENFORCED_ON_CONTRACT_VIOLATION) - -#define GSL_CONTRACT_CHECK(type, cond) GSL_ASSUME(cond) - -#endif - -#define Expects(cond) GSL_CONTRACT_CHECK("Precondition", cond) -#define Ensures(cond) GSL_CONTRACT_CHECK("Postcondition", cond) - -#endif // GSL_CONTRACTS_H diff --git a/inst/include/gsl/gsl_byte b/inst/include/gsl/gsl_byte deleted file mode 100644 index e861173..0000000 --- a/inst/include/gsl/gsl_byte +++ /dev/null @@ -1,181 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GSL_BYTE_H -#define GSL_BYTE_H - -#include - -#ifdef _MSC_VER - -#pragma warning(push) - -// don't warn about function style casts in byte related operators -#pragma warning(disable : 26493) - -#ifndef GSL_USE_STD_BYTE -// this tests if we are under MSVC and the standard lib has std::byte and it is enabled -#if defined(_HAS_STD_BYTE) && _HAS_STD_BYTE - -#define GSL_USE_STD_BYTE 1 - -#else // defined(_HAS_STD_BYTE) && _HAS_STD_BYTE - -#define GSL_USE_STD_BYTE 0 - -#endif // defined(_HAS_STD_BYTE) && _HAS_STD_BYTE -#endif // GSL_USE_STD_BYTE - -#else // _MSC_VER - -#ifndef GSL_USE_STD_BYTE -// this tests if we are under GCC or Clang with enough -std:c++1z power to get us std::byte -#if defined(__cplusplus) && (__cplusplus >= 201703L) - -#define GSL_USE_STD_BYTE 1 -#include - -#else // defined(__cplusplus) && (__cplusplus >= 201703L) - -#define GSL_USE_STD_BYTE 0 - -#endif //defined(__cplusplus) && (__cplusplus >= 201703L) -#endif // GSL_USE_STD_BYTE - -#endif // _MSC_VER - -// Use __may_alias__ attribute on gcc and clang -#if defined __clang__ || (__GNUC__ > 5) -#define byte_may_alias __attribute__((__may_alias__)) -#else // defined __clang__ || defined __GNUC__ -#define byte_may_alias -#endif // defined __clang__ || defined __GNUC__ - -namespace gsl -{ -#if GSL_USE_STD_BYTE - - -using std::byte; -using std::to_integer; - -#else // GSL_USE_STD_BYTE - -// This is a simple definition for now that allows -// use of byte within span<> to be standards-compliant -enum class byte_may_alias byte : unsigned char -{ -}; - -template ::value>> -constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept -{ - return b = byte(static_cast(b) << shift); -} - -template ::value>> -constexpr byte operator<<(byte b, IntegerType shift) noexcept -{ - return byte(static_cast(b) << shift); -} - -template ::value>> -constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept -{ - return b = byte(static_cast(b) >> shift); -} - -template ::value>> -constexpr byte operator>>(byte b, IntegerType shift) noexcept -{ - return byte(static_cast(b) >> shift); -} - -constexpr byte& operator|=(byte& l, byte r) noexcept -{ - return l = byte(static_cast(l) | static_cast(r)); -} - -constexpr byte operator|(byte l, byte r) noexcept -{ - return byte(static_cast(l) | static_cast(r)); -} - -constexpr byte& operator&=(byte& l, byte r) noexcept -{ - return l = byte(static_cast(l) & static_cast(r)); -} - -constexpr byte operator&(byte l, byte r) noexcept -{ - return byte(static_cast(l) & static_cast(r)); -} - -constexpr byte& operator^=(byte& l, byte r) noexcept -{ - return l = byte(static_cast(l) ^ static_cast(r)); -} - -constexpr byte operator^(byte l, byte r) noexcept -{ - return byte(static_cast(l) ^ static_cast(r)); -} - -constexpr byte operator~(byte b) noexcept { return byte(~static_cast(b)); } - -template ::value>> -constexpr IntegerType to_integer(byte b) noexcept -{ - return static_cast(b); -} - -#endif // GSL_USE_STD_BYTE - -template -constexpr byte to_byte_impl(T t) noexcept -{ - static_assert( - E, "gsl::to_byte(t) must be provided an unsigned char, otherwise data loss may occur. " - "If you are calling to_byte with an integer contant use: gsl::to_byte() version."); - return static_cast(t); -} -template <> -constexpr byte to_byte_impl(unsigned char t) noexcept -{ - return byte(t); -} - -template -constexpr byte to_byte(T t) noexcept -{ - return to_byte_impl::value, T>(t); -} - -template -constexpr byte to_byte() noexcept -{ - static_assert(I >= 0 && I <= 255, - "gsl::byte only has 8 bits of storage, values must be in range 0-255"); - return static_cast(I); -} - -} // namespace gsl - -#ifdef _MSC_VER -#pragma warning(pop) -#endif // _MSC_VER - -#endif // GSL_BYTE_H diff --git a/inst/include/gsl/gsl_util b/inst/include/gsl/gsl_util deleted file mode 100644 index 25f8502..0000000 --- a/inst/include/gsl/gsl_util +++ /dev/null @@ -1,158 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GSL_UTIL_H -#define GSL_UTIL_H - -#include // for Expects - -#include -#include // for ptrdiff_t, size_t -#include // for exception -#include // for initializer_list -#include // for is_signed, integral_constant -#include // for forward - -#if defined(_MSC_VER) - -#pragma warning(push) -#pragma warning(disable : 4127) // conditional expression is constant - -#if _MSC_VER < 1910 -#pragma push_macro("constexpr") -#define constexpr /*constexpr*/ -#endif // _MSC_VER < 1910 -#endif // _MSC_VER - -namespace gsl -{ -// -// GSL.util: utilities -// - -// index type for all container indexes/subscripts/sizes -using index = std::ptrdiff_t; - -// final_action allows you to ensure something gets run at the end of a scope -template -class final_action -{ -public: - explicit final_action(F f) noexcept : f_(std::move(f)) {} - - final_action(final_action&& other) noexcept : f_(std::move(other.f_)), invoke_(other.invoke_) - { - other.invoke_ = false; - } - - final_action(const final_action&) = delete; - final_action& operator=(const final_action&) = delete; - final_action& operator=(final_action&&) = delete; - - ~final_action() noexcept - { - if (invoke_) f_(); - } - -private: - F f_; - bool invoke_ {true}; -}; - -// finally() - convenience function to generate a final_action -template - -final_action finally(const F& f) noexcept -{ - return final_action(f); -} - -template -final_action finally(F&& f) noexcept -{ - return final_action(std::forward(f)); -} - -// narrow_cast(): a searchable way to do narrowing casts of values -template -constexpr T narrow_cast(U&& u) noexcept -{ - return static_cast(std::forward(u)); -} - -struct narrowing_error : public std::exception -{ -}; - -namespace details -{ - template - struct is_same_signedness - : public std::integral_constant::value == std::is_signed::value> - { - }; -} - -// narrow() : a checked version of narrow_cast() that throws if the cast changed the value -template -T narrow(U u) -{ - T t = narrow_cast(u); - if (static_cast(t) != u) gsl::details::throw_exception(narrowing_error()); - if (!details::is_same_signedness::value && ((t < T{}) != (u < U{}))) - gsl::details::throw_exception(narrowing_error()); - return t; -} - -// -// at() - Bounds-checked way of accessing builtin arrays, std::array, std::vector -// -template -constexpr T& at(T (&arr)[N], const index i) -{ - Expects(i >= 0 && i < narrow_cast(N)); - return arr[static_cast(i)]; -} - -template -constexpr auto at(Cont& cont, const index i) -> decltype(cont[cont.size()]) -{ - Expects(i >= 0 && i < narrow_cast(cont.size())); - using size_type = decltype(cont.size()); - return cont[static_cast(i)]; -} - -template -constexpr T at(const std::initializer_list cont, const index i) -{ - Expects(i >= 0 && i < narrow_cast(cont.size())); - return *(cont.begin() + i); -} - -} // namespace gsl - -#if defined(_MSC_VER) -#if _MSC_VER < 1910 -#undef constexpr -#pragma pop_macro("constexpr") - -#endif // _MSC_VER < 1910 - -#pragma warning(pop) - -#endif // _MSC_VER - -#endif // GSL_UTIL_H diff --git a/inst/include/gsl/multi_span b/inst/include/gsl/multi_span deleted file mode 100644 index f697093..0000000 --- a/inst/include/gsl/multi_span +++ /dev/null @@ -1,2242 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GSL_MULTI_SPAN_H -#define GSL_MULTI_SPAN_H - -#include // for Expects -#include // for byte -#include // for narrow_cast - -#include // for transform, lexicographical_compare -#include // for array -#include -#include // for ptrdiff_t, size_t, nullptr_t -#include // for PTRDIFF_MAX -#include // for divides, multiplies, minus, negate, plus -#include // for initializer_list -#include // for iterator, random_access_iterator_tag -#include // for numeric_limits -#include -#include -#include -#include // for basic_string -#include // for enable_if_t, remove_cv_t, is_same, is_co... -#include - -#ifdef _MSC_VER - -// turn off some warnings that are noisy about our Expects statements -#pragma warning(push) -#pragma warning(disable : 4127) // conditional expression is constant -#pragma warning(disable : 4702) // unreachable code - -#if _MSC_VER < 1910 -#pragma push_macro("constexpr") -#define constexpr /*constexpr*/ - -#endif // _MSC_VER < 1910 -#endif // _MSC_VER - -// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t) -// While there is a conversion from signed to unsigned, it happens at -// compiletime, so the compiler wouldn't have to warn indiscriminently, but -// could check if the source value actually doesn't fit into the target type -// and only warn in those cases. -#if __GNUC__ > 6 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-conversion" -#endif - -#ifdef GSL_THROW_ON_CONTRACT_VIOLATION -#define GSL_NOEXCEPT /*noexcept*/ -#else -#define GSL_NOEXCEPT noexcept -#endif // GSL_THROW_ON_CONTRACT_VIOLATION - -namespace gsl -{ - -/* -** begin definitions of index and bounds -*/ -namespace details -{ - template - struct SizeTypeTraits - { - static const SizeType max_value = std::numeric_limits::max(); - }; - - template - class are_integral : public std::integral_constant - { - }; - - template - class are_integral - : public std::integral_constant::value && are_integral::value> - { - }; -} - -template -class multi_span_index final -{ - static_assert(Rank > 0, "Rank must be greater than 0!"); - - template - friend class multi_span_index; - -public: - static const std::size_t rank = Rank; - using value_type = std::ptrdiff_t; - using size_type = value_type; - using reference = std::add_lvalue_reference_t; - using const_reference = std::add_lvalue_reference_t>; - - constexpr multi_span_index() GSL_NOEXCEPT {} - - constexpr multi_span_index(const value_type (&values)[Rank]) GSL_NOEXCEPT - { - std::copy(values, values + Rank, elems); - } - - template ::value>> - constexpr multi_span_index(Ts... ds) GSL_NOEXCEPT : elems{narrow_cast(ds)...} - { - } - - constexpr multi_span_index(const multi_span_index& other) GSL_NOEXCEPT = default; - - constexpr multi_span_index& operator=(const multi_span_index& rhs) GSL_NOEXCEPT = default; - - // Preconditions: component_idx < rank - constexpr reference operator[](std::size_t component_idx) - { - Expects(component_idx < Rank); // Component index must be less than rank - return elems[component_idx]; - } - - // Preconditions: component_idx < rank - constexpr const_reference operator[](std::size_t component_idx) const GSL_NOEXCEPT - { - Expects(component_idx < Rank); // Component index must be less than rank - return elems[component_idx]; - } - - constexpr bool operator==(const multi_span_index& rhs) const GSL_NOEXCEPT - { - return std::equal(elems, elems + rank, rhs.elems); - } - - constexpr bool operator!=(const multi_span_index& rhs) const GSL_NOEXCEPT { return !(*this == rhs); } - - constexpr multi_span_index operator+() const GSL_NOEXCEPT { return *this; } - - constexpr multi_span_index operator-() const GSL_NOEXCEPT - { - multi_span_index ret = *this; - std::transform(ret, ret + rank, ret, std::negate{}); - return ret; - } - - constexpr multi_span_index operator+(const multi_span_index& rhs) const GSL_NOEXCEPT - { - multi_span_index ret = *this; - ret += rhs; - return ret; - } - - constexpr multi_span_index operator-(const multi_span_index& rhs) const GSL_NOEXCEPT - { - multi_span_index ret = *this; - ret -= rhs; - return ret; - } - - constexpr multi_span_index& operator+=(const multi_span_index& rhs) GSL_NOEXCEPT - { - std::transform(elems, elems + rank, rhs.elems, elems, std::plus{}); - return *this; - } - - constexpr multi_span_index& operator-=(const multi_span_index& rhs) GSL_NOEXCEPT - { - std::transform(elems, elems + rank, rhs.elems, elems, std::minus{}); - return *this; - } - - constexpr multi_span_index operator*(value_type v) const GSL_NOEXCEPT - { - multi_span_index ret = *this; - ret *= v; - return ret; - } - - constexpr multi_span_index operator/(value_type v) const GSL_NOEXCEPT - { - multi_span_index ret = *this; - ret /= v; - return ret; - } - - friend constexpr multi_span_index operator*(value_type v, const multi_span_index& rhs) GSL_NOEXCEPT - { - return rhs * v; - } - - constexpr multi_span_index& operator*=(value_type v) GSL_NOEXCEPT - { - std::transform(elems, elems + rank, elems, - [v](value_type x) { return std::multiplies{}(x, v); }); - return *this; - } - - constexpr multi_span_index& operator/=(value_type v) GSL_NOEXCEPT - { - std::transform(elems, elems + rank, elems, - [v](value_type x) { return std::divides{}(x, v); }); - return *this; - } - -private: - value_type elems[Rank] = {}; -}; - -#if !defined(_MSC_VER) || _MSC_VER >= 1910 - -struct static_bounds_dynamic_range_t -{ - template ::value>> - constexpr operator T() const GSL_NOEXCEPT - { - return narrow_cast(-1); - } -}; - -constexpr bool operator==(static_bounds_dynamic_range_t, static_bounds_dynamic_range_t) GSL_NOEXCEPT -{ - return true; -} - -constexpr bool operator!=(static_bounds_dynamic_range_t, static_bounds_dynamic_range_t) GSL_NOEXCEPT -{ - return false; -} - -template ::value>> -constexpr bool operator==(static_bounds_dynamic_range_t, T other) GSL_NOEXCEPT -{ - return narrow_cast(-1) == other; -} - -template ::value>> -constexpr bool operator==(T left, static_bounds_dynamic_range_t right) GSL_NOEXCEPT -{ - return right == left; -} - -template ::value>> -constexpr bool operator!=(static_bounds_dynamic_range_t, T other) GSL_NOEXCEPT -{ - return narrow_cast(-1) != other; -} - -template ::value>> -constexpr bool operator!=(T left, static_bounds_dynamic_range_t right) GSL_NOEXCEPT -{ - return right != left; -} - -constexpr static_bounds_dynamic_range_t dynamic_range{}; -#else -const std::ptrdiff_t dynamic_range = -1; -#endif - -struct generalized_mapping_tag -{ -}; -struct contiguous_mapping_tag : generalized_mapping_tag -{ -}; - -namespace details -{ - - template - struct LessThan - { - static const bool value = Left < Right; - }; - - template - struct BoundsRanges - { - using size_type = std::ptrdiff_t; - static const size_type Depth = 0; - static const size_type DynamicNum = 0; - static const size_type CurrentRange = 1; - static const size_type TotalSize = 1; - - // TODO : following signature is for work around VS bug - template - BoundsRanges(const OtherRange&, bool /* firstLevel */) - { - } - - BoundsRanges(const std::ptrdiff_t* const) {} - BoundsRanges() = default; - - template - void serialize(T&) const - { - } - - template - size_type linearize(const T&) const - { - return 0; - } - - template - size_type contains(const T&) const - { - return -1; - } - - size_type elementNum(std::size_t) const GSL_NOEXCEPT { return 0; } - - size_type totalSize() const GSL_NOEXCEPT { return TotalSize; } - - bool operator==(const BoundsRanges&) const GSL_NOEXCEPT { return true; } - }; - - template - struct BoundsRanges : BoundsRanges - { - using Base = BoundsRanges; - using size_type = std::ptrdiff_t; - static const std::size_t Depth = Base::Depth + 1; - static const std::size_t DynamicNum = Base::DynamicNum + 1; - static const size_type CurrentRange = dynamic_range; - static const size_type TotalSize = dynamic_range; - - private: - size_type m_bound; - - public: - BoundsRanges(const std::ptrdiff_t* const arr) - : Base(arr + 1), m_bound(*arr * this->Base::totalSize()) - { - Expects(0 <= *arr); - } - - BoundsRanges() : m_bound(0) {} - - template - BoundsRanges(const BoundsRanges& other, - bool /* firstLevel */ = true) - : Base(static_cast&>(other), false) - , m_bound(other.totalSize()) - { - } - - template - void serialize(T& arr) const - { - arr[Dim] = elementNum(); - this->Base::template serialize(arr); - } - - template - size_type linearize(const T& arr) const - { - const size_type index = this->Base::totalSize() * arr[Dim]; - Expects(index < m_bound); - return index + this->Base::template linearize(arr); - } - - template - size_type contains(const T& arr) const - { - const ptrdiff_t last = this->Base::template contains(arr); - if (last == -1) return -1; - const ptrdiff_t cur = this->Base::totalSize() * arr[Dim]; - return cur < m_bound ? cur + last : -1; - } - - size_type totalSize() const GSL_NOEXCEPT { return m_bound; } - - size_type elementNum() const GSL_NOEXCEPT { return totalSize() / this->Base::totalSize(); } - - size_type elementNum(std::size_t dim) const GSL_NOEXCEPT - { - if (dim > 0) - return this->Base::elementNum(dim - 1); - else - return elementNum(); - } - - bool operator==(const BoundsRanges& rhs) const GSL_NOEXCEPT - { - return m_bound == rhs.m_bound && - static_cast(*this) == static_cast(rhs); - } - }; - - template - struct BoundsRanges : BoundsRanges - { - using Base = BoundsRanges; - using size_type = std::ptrdiff_t; - static const std::size_t Depth = Base::Depth + 1; - static const std::size_t DynamicNum = Base::DynamicNum; - static const size_type CurrentRange = CurRange; - static const size_type TotalSize = - Base::TotalSize == dynamic_range ? dynamic_range : CurrentRange * Base::TotalSize; - - BoundsRanges(const std::ptrdiff_t* const arr) : Base(arr) {} - BoundsRanges() = default; - - template - BoundsRanges(const BoundsRanges& other, - bool firstLevel = true) - : Base(static_cast&>(other), false) - { - (void) firstLevel; - } - - template - void serialize(T& arr) const - { - arr[Dim] = elementNum(); - this->Base::template serialize(arr); - } - - template - size_type linearize(const T& arr) const - { - Expects(arr[Dim] >= 0 && arr[Dim] < CurrentRange); // Index is out of range - return this->Base::totalSize() * arr[Dim] + - this->Base::template linearize(arr); - } - - template - size_type contains(const T& arr) const - { - if (arr[Dim] >= CurrentRange) return -1; - const size_type last = this->Base::template contains(arr); - if (last == -1) return -1; - return this->Base::totalSize() * arr[Dim] + last; - } - - size_type totalSize() const GSL_NOEXCEPT { return CurrentRange * this->Base::totalSize(); } - - size_type elementNum() const GSL_NOEXCEPT { return CurrentRange; } - - size_type elementNum(std::size_t dim) const GSL_NOEXCEPT - { - if (dim > 0) - return this->Base::elementNum(dim - 1); - else - return elementNum(); - } - - bool operator==(const BoundsRanges& rhs) const GSL_NOEXCEPT - { - return static_cast(*this) == static_cast(rhs); - } - }; - - template - struct BoundsRangeConvertible - : public std::integral_constant= TargetType::TotalSize || - TargetType::TotalSize == dynamic_range || - SourceType::TotalSize == dynamic_range || - TargetType::TotalSize == 0)> - { - }; - - template - struct TypeListIndexer - { - const TypeChain& obj_; - TypeListIndexer(const TypeChain& obj) : obj_(obj) {} - - template - const TypeChain& getObj(std::true_type) - { - return obj_; - } - - template - auto getObj(std::false_type) - -> decltype(TypeListIndexer(static_cast(obj_)).template get()) - { - return TypeListIndexer(static_cast(obj_)).template get(); - } - - template - auto get() -> decltype(getObj(std::integral_constant())) - { - return getObj(std::integral_constant()); - } - }; - - template - TypeListIndexer createTypeListIndexer(const TypeChain& obj) - { - return TypeListIndexer(obj); - } - - template 1), - typename Ret = std::enable_if_t>> - constexpr Ret shift_left(const multi_span_index& other) GSL_NOEXCEPT - { - Ret ret{}; - for (std::size_t i = 0; i < Rank - 1; ++i) { - ret[i] = other[i + 1]; - } - return ret; - } -} - -template -class bounds_iterator; - -template -class static_bounds -{ -public: - static_bounds(const details::BoundsRanges&) {} -}; - -template -class static_bounds -{ - using MyRanges = details::BoundsRanges; - - MyRanges m_ranges; - constexpr static_bounds(const MyRanges& range) : m_ranges(range) {} - - template - friend class static_bounds; - -public: - static const std::size_t rank = MyRanges::Depth; - static const std::size_t dynamic_rank = MyRanges::DynamicNum; - static const std::ptrdiff_t static_size = MyRanges::TotalSize; - - using size_type = std::ptrdiff_t; - using index_type = multi_span_index; - using const_index_type = std::add_const_t; - using iterator = bounds_iterator; - using const_iterator = bounds_iterator; - using difference_type = std::ptrdiff_t; - using sliced_type = static_bounds; - using mapping_type = contiguous_mapping_tag; - - constexpr static_bounds(const static_bounds&) = default; - - template - struct BoundsRangeConvertible2; - - template > - static auto helpBoundsRangeConvertible(SourceType, TargetType, std::true_type) -> Ret; - - template - static auto helpBoundsRangeConvertible(SourceType, TargetType, ...) -> std::false_type; - - template - struct BoundsRangeConvertible2 - : decltype(helpBoundsRangeConvertible( - SourceType(), TargetType(), - std::integral_constant())) - { - }; - - template - struct BoundsRangeConvertible2 : std::true_type - { - }; - - template - struct BoundsRangeConvertible - : decltype(helpBoundsRangeConvertible( - SourceType(), TargetType(), - std::integral_constant::value || - TargetType::CurrentRange == dynamic_range || - SourceType::CurrentRange == dynamic_range)>())) - { - }; - - template - struct BoundsRangeConvertible : std::true_type - { - }; - - template , - details::BoundsRanges>::value>> - constexpr static_bounds(const static_bounds& other) : m_ranges(other.m_ranges) - { - Expects((MyRanges::DynamicNum == 0 && details::BoundsRanges::DynamicNum == 0) || - MyRanges::DynamicNum > 0 || other.m_ranges.totalSize() >= m_ranges.totalSize()); - } - - constexpr static_bounds(std::initializer_list il) - : m_ranges(static_cast(il.begin())) - { - // Size of the initializer list must match the rank of the array - Expects((MyRanges::DynamicNum == 0 && il.size() == 1 && *il.begin() == static_size) || - MyRanges::DynamicNum == il.size()); - // Size of the range must be less than the max element of the size type - Expects(m_ranges.totalSize() <= PTRDIFF_MAX); - } - - constexpr static_bounds() = default; - - constexpr sliced_type slice() const GSL_NOEXCEPT - { - return sliced_type{static_cast&>(m_ranges)}; - } - - constexpr size_type stride() const GSL_NOEXCEPT { return rank > 1 ? slice().size() : 1; } - - constexpr size_type size() const GSL_NOEXCEPT { return m_ranges.totalSize(); } - - constexpr size_type total_size() const GSL_NOEXCEPT { return m_ranges.totalSize(); } - - constexpr size_type linearize(const index_type& idx) const { return m_ranges.linearize(idx); } - - constexpr bool contains(const index_type& idx) const GSL_NOEXCEPT - { - return m_ranges.contains(idx) != -1; - } - - constexpr size_type operator[](std::size_t idx) const GSL_NOEXCEPT - { - return m_ranges.elementNum(idx); - } - - template - constexpr size_type extent() const GSL_NOEXCEPT - { - static_assert(Dim < rank, - "dimension should be less than rank (dimension count starts from 0)"); - return details::createTypeListIndexer(m_ranges).template get().elementNum(); - } - - template - constexpr size_type extent(IntType dim) const GSL_NOEXCEPT - { - static_assert(std::is_integral::value, - "Dimension parameter must be supplied as an integral type."); - auto real_dim = narrow_cast(dim); - Expects(real_dim < rank); - - return m_ranges.elementNum(real_dim); - } - - constexpr index_type index_bounds() const GSL_NOEXCEPT - { - size_type extents[rank] = {}; - m_ranges.serialize(extents); - return {extents}; - } - - template - constexpr bool operator==(const static_bounds& rhs) const GSL_NOEXCEPT - { - return this->size() == rhs.size(); - } - - template - constexpr bool operator!=(const static_bounds& rhs) const GSL_NOEXCEPT - { - return !(*this == rhs); - } - - constexpr const_iterator begin() const GSL_NOEXCEPT - { - return const_iterator(*this, index_type{}); - } - - constexpr const_iterator end() const GSL_NOEXCEPT - { - return const_iterator(*this, this->index_bounds()); - } -}; - -template -class strided_bounds -{ - template - friend class strided_bounds; - -public: - static const std::size_t rank = Rank; - using value_type = std::ptrdiff_t; - using reference = std::add_lvalue_reference_t; - using const_reference = std::add_const_t; - using size_type = value_type; - using difference_type = value_type; - using index_type = multi_span_index; - using const_index_type = std::add_const_t; - using iterator = bounds_iterator; - using const_iterator = bounds_iterator; - static const value_type dynamic_rank = rank; - static const value_type static_size = dynamic_range; - using sliced_type = std::conditional_t, void>; - using mapping_type = generalized_mapping_tag; - - constexpr strided_bounds(const strided_bounds&) GSL_NOEXCEPT = default; - - constexpr strided_bounds& operator=(const strided_bounds&) GSL_NOEXCEPT = default; - - constexpr strided_bounds(const value_type (&values)[rank], index_type strides) - : m_extents(values), m_strides(std::move(strides)) - { - } - - constexpr strided_bounds(const index_type& extents, const index_type& strides) GSL_NOEXCEPT - : m_extents(extents), - m_strides(strides) - { - } - - constexpr index_type strides() const GSL_NOEXCEPT { return m_strides; } - - constexpr size_type total_size() const GSL_NOEXCEPT - { - size_type ret = 0; - for (std::size_t i = 0; i < rank; ++i) { - ret += (m_extents[i] - 1) * m_strides[i]; - } - return ret + 1; - } - - constexpr size_type size() const GSL_NOEXCEPT - { - size_type ret = 1; - for (std::size_t i = 0; i < rank; ++i) { - ret *= m_extents[i]; - } - return ret; - } - - constexpr bool contains(const index_type& idx) const GSL_NOEXCEPT - { - for (std::size_t i = 0; i < rank; ++i) { - if (idx[i] < 0 || idx[i] >= m_extents[i]) return false; - } - return true; - } - - constexpr size_type linearize(const index_type& idx) const GSL_NOEXCEPT - { - size_type ret = 0; - for (std::size_t i = 0; i < rank; i++) { - Expects(idx[i] < m_extents[i]); // index is out of bounds of the array - ret += idx[i] * m_strides[i]; - } - return ret; - } - - constexpr size_type stride() const GSL_NOEXCEPT { return m_strides[0]; } - - template 1), typename Ret = std::enable_if_t> - constexpr sliced_type slice() const - { - return {details::shift_left(m_extents), details::shift_left(m_strides)}; - } - - template - constexpr size_type extent() const GSL_NOEXCEPT - { - static_assert(Dim < Rank, - "dimension should be less than rank (dimension count starts from 0)"); - return m_extents[Dim]; - } - - constexpr index_type index_bounds() const GSL_NOEXCEPT { return m_extents; } - constexpr const_iterator begin() const GSL_NOEXCEPT - { - return const_iterator{*this, index_type{}}; - } - - constexpr const_iterator end() const GSL_NOEXCEPT - { - return const_iterator{*this, index_bounds()}; - } - -private: - index_type m_extents; - index_type m_strides; -}; - -template -struct is_bounds : std::integral_constant -{ -}; -template -struct is_bounds> : std::integral_constant -{ -}; -template -struct is_bounds> : std::integral_constant -{ -}; - -template -class bounds_iterator -{ -public: - static const std::size_t rank = IndexType::rank; - using iterator_category = std::random_access_iterator_tag; - using value_type = IndexType; - using difference_type = std::ptrdiff_t; - using pointer = value_type*; - using reference = value_type&; - using index_type = value_type; - using index_size_type = typename IndexType::value_type; - template - explicit bounds_iterator(const Bounds& bnd, value_type curr) GSL_NOEXCEPT - : boundary_(bnd.index_bounds()), - curr_(std::move(curr)) - { - static_assert(is_bounds::value, "Bounds type must be provided"); - } - - constexpr reference operator*() const GSL_NOEXCEPT { return curr_; } - - constexpr pointer operator->() const GSL_NOEXCEPT { return &curr_; } - - constexpr bounds_iterator& operator++() GSL_NOEXCEPT - { - for (std::size_t i = rank; i-- > 0;) { - if (curr_[i] < boundary_[i] - 1) { - curr_[i]++; - return *this; - } - curr_[i] = 0; - } - // If we're here we've wrapped over - set to past-the-end. - curr_ = boundary_; - return *this; - } - - constexpr bounds_iterator operator++(int) GSL_NOEXCEPT - { - auto ret = *this; - ++(*this); - return ret; - } - - constexpr bounds_iterator& operator--() GSL_NOEXCEPT - { - if (!less(curr_, boundary_)) { - // if at the past-the-end, set to last element - for (std::size_t i = 0; i < rank; ++i) { - curr_[i] = boundary_[i] - 1; - } - return *this; - } - for (std::size_t i = rank; i-- > 0;) { - if (curr_[i] >= 1) { - curr_[i]--; - return *this; - } - curr_[i] = boundary_[i] - 1; - } - // If we're here the preconditions were violated - // "pre: there exists s such that r == ++s" - Expects(false); - return *this; - } - - constexpr bounds_iterator operator--(int) GSL_NOEXCEPT - { - auto ret = *this; - --(*this); - return ret; - } - - constexpr bounds_iterator operator+(difference_type n) const GSL_NOEXCEPT - { - bounds_iterator ret{*this}; - return ret += n; - } - - constexpr bounds_iterator& operator+=(difference_type n) GSL_NOEXCEPT - { - auto linear_idx = linearize(curr_) + n; - std::remove_const_t stride = 0; - stride[rank - 1] = 1; - for (std::size_t i = rank - 1; i-- > 0;) { - stride[i] = stride[i + 1] * boundary_[i + 1]; - } - for (std::size_t i = 0; i < rank; ++i) { - curr_[i] = linear_idx / stride[i]; - linear_idx = linear_idx % stride[i]; - } - // index is out of bounds of the array - Expects(!less(curr_, index_type{}) && !less(boundary_, curr_)); - return *this; - } - - constexpr bounds_iterator operator-(difference_type n) const GSL_NOEXCEPT - { - bounds_iterator ret{*this}; - return ret -= n; - } - - constexpr bounds_iterator& operator-=(difference_type n) GSL_NOEXCEPT { return *this += -n; } - - constexpr difference_type operator-(const bounds_iterator& rhs) const GSL_NOEXCEPT - { - return linearize(curr_) - linearize(rhs.curr_); - } - - constexpr value_type operator[](difference_type n) const GSL_NOEXCEPT { return *(*this + n); } - - constexpr bool operator==(const bounds_iterator& rhs) const GSL_NOEXCEPT - { - return curr_ == rhs.curr_; - } - - constexpr bool operator!=(const bounds_iterator& rhs) const GSL_NOEXCEPT - { - return !(*this == rhs); - } - - constexpr bool operator<(const bounds_iterator& rhs) const GSL_NOEXCEPT - { - return less(curr_, rhs.curr_); - } - - constexpr bool operator<=(const bounds_iterator& rhs) const GSL_NOEXCEPT - { - return !(rhs < *this); - } - - constexpr bool operator>(const bounds_iterator& rhs) const GSL_NOEXCEPT { return rhs < *this; } - - constexpr bool operator>=(const bounds_iterator& rhs) const GSL_NOEXCEPT - { - return !(rhs > *this); - } - - void swap(bounds_iterator& rhs) GSL_NOEXCEPT - { - std::swap(boundary_, rhs.boundary_); - std::swap(curr_, rhs.curr_); - } - -private: - constexpr bool less(index_type& one, index_type& other) const GSL_NOEXCEPT - { - for (std::size_t i = 0; i < rank; ++i) { - if (one[i] < other[i]) return true; - } - return false; - } - - constexpr index_size_type linearize(const value_type& idx) const GSL_NOEXCEPT - { - // TODO: Smarter impl. - // Check if past-the-end - index_size_type multiplier = 1; - index_size_type res = 0; - if (!less(idx, boundary_)) { - res = 1; - for (std::size_t i = rank; i-- > 0;) { - res += (idx[i] - 1) * multiplier; - multiplier *= boundary_[i]; - } - } - else - { - for (std::size_t i = rank; i-- > 0;) { - res += idx[i] * multiplier; - multiplier *= boundary_[i]; - } - } - return res; - } - - value_type boundary_; - std::remove_const_t curr_; -}; - -template -bounds_iterator operator+(typename bounds_iterator::difference_type n, - const bounds_iterator& rhs) GSL_NOEXCEPT -{ - return rhs + n; -} - -namespace details -{ - template - constexpr std::enable_if_t< - std::is_same::value, - typename Bounds::index_type> - make_stride(const Bounds& bnd) GSL_NOEXCEPT - { - return bnd.strides(); - } - - // Make a stride vector from bounds, assuming contiguous memory. - template - constexpr std::enable_if_t< - std::is_same::value, - typename Bounds::index_type> - make_stride(const Bounds& bnd) GSL_NOEXCEPT - { - auto extents = bnd.index_bounds(); - typename Bounds::size_type stride[Bounds::rank] = {}; - - stride[Bounds::rank - 1] = 1; - for (std::size_t i = 1; i < Bounds::rank; ++i) { - stride[Bounds::rank - i - 1] = stride[Bounds::rank - i] * extents[Bounds::rank - i]; - } - return {stride}; - } - - template - void verifyBoundsReshape(const BoundsSrc& src, const BoundsDest& dest) - { - static_assert(is_bounds::value && is_bounds::value, - "The src type and dest type must be bounds"); - static_assert(std::is_same::value, - "The source type must be a contiguous bounds"); - static_assert(BoundsDest::static_size == dynamic_range || - BoundsSrc::static_size == dynamic_range || - BoundsDest::static_size == BoundsSrc::static_size, - "The source bounds must have same size as dest bounds"); - Expects(src.size() == dest.size()); - } - -} // namespace details - -template -class contiguous_span_iterator; -template -class general_span_iterator; - -template -struct dim_t -{ - static const std::ptrdiff_t value = DimSize; -}; -template <> -struct dim_t -{ - static const std::ptrdiff_t value = dynamic_range; - const std::ptrdiff_t dvalue; - constexpr dim_t(std::ptrdiff_t size) GSL_NOEXCEPT : dvalue(size) {} -}; - -template = 0)>> -constexpr dim_t dim() GSL_NOEXCEPT -{ - return dim_t(); -} - -template > -constexpr dim_t dim(std::ptrdiff_t n) GSL_NOEXCEPT -{ - return dim_t<>(n); -} - -template -class multi_span; -template -class strided_span; - -namespace details -{ - template - struct SpanTypeTraits - { - using value_type = T; - using size_type = std::size_t; - }; - - template - struct SpanTypeTraits::type> - { - using value_type = typename Traits::span_traits::value_type; - using size_type = typename Traits::span_traits::size_type; - }; - - template - struct SpanArrayTraits - { - using type = multi_span; - using value_type = T; - using bounds_type = static_bounds; - using pointer = T*; - using reference = T&; - }; - template - struct SpanArrayTraits : SpanArrayTraits - { - }; - - template - BoundsType newBoundsHelperImpl(std::ptrdiff_t totalSize, std::true_type) // dynamic size - { - Expects(totalSize >= 0 && totalSize <= PTRDIFF_MAX); - return BoundsType{totalSize}; - } - template - BoundsType newBoundsHelperImpl(std::ptrdiff_t totalSize, std::false_type) // static size - { - Expects(BoundsType::static_size <= totalSize); - return {}; - } - template - BoundsType newBoundsHelper(std::ptrdiff_t totalSize) - { - static_assert(BoundsType::dynamic_rank <= 1, "dynamic rank must less or equal to 1"); - return newBoundsHelperImpl( - totalSize, std::integral_constant()); - } - - struct Sep - { - }; - - template - T static_as_multi_span_helper(Sep, Args... args) - { - return T{narrow_cast(args)...}; - } - template - std::enable_if_t< - !std::is_same>::value && !std::is_same::value, T> - static_as_multi_span_helper(Arg, Args... args) - { - return static_as_multi_span_helper(args...); - } - template - T static_as_multi_span_helper(dim_t val, Args... args) - { - return static_as_multi_span_helper(args..., val.dvalue); - } - - template - struct static_as_multi_span_static_bounds_helper - { - using type = static_bounds<(Dimensions::value)...>; - }; - - template - struct is_multi_span_oracle : std::false_type - { - }; - - template - struct is_multi_span_oracle> - : std::true_type - { - }; - - template - struct is_multi_span_oracle> : std::true_type - { - }; - - template - struct is_multi_span : is_multi_span_oracle> - { - }; -} - -template -class multi_span -{ - // TODO do we still need this? - template - friend class multi_span; - -public: - using bounds_type = static_bounds; - static const std::size_t Rank = bounds_type::rank; - using size_type = typename bounds_type::size_type; - using index_type = typename bounds_type::index_type; - using value_type = ValueType; - using const_value_type = std::add_const_t; - using pointer = std::add_pointer_t; - using reference = std::add_lvalue_reference_t; - using iterator = contiguous_span_iterator; - using const_span = multi_span; - using const_iterator = contiguous_span_iterator; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - using sliced_type = - std::conditional_t>; - -private: - pointer data_; - bounds_type bounds_; - - friend iterator; - friend const_iterator; - -public: - // default constructor - same as constructing from nullptr_t - constexpr multi_span() GSL_NOEXCEPT : multi_span(nullptr, bounds_type{}) - { - static_assert(bounds_type::dynamic_rank != 0 || - (bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0), - "Default construction of multi_span only possible " - "for dynamic or fixed, zero-length spans."); - } - - // construct from nullptr - get an empty multi_span - constexpr multi_span(std::nullptr_t) GSL_NOEXCEPT : multi_span(nullptr, bounds_type{}) - { - static_assert(bounds_type::dynamic_rank != 0 || - (bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0), - "nullptr_t construction of multi_span only possible " - "for dynamic or fixed, zero-length spans."); - } - - // construct from nullptr with size of 0 (helps with template function calls) - template ::value>> - constexpr multi_span(std::nullptr_t, IntType size) GSL_NOEXCEPT - : multi_span(nullptr, bounds_type{}) - { - static_assert(bounds_type::dynamic_rank != 0 || - (bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0), - "nullptr_t construction of multi_span only possible " - "for dynamic or fixed, zero-length spans."); - Expects(size == 0); - } - - // construct from a single element - constexpr multi_span(reference data) GSL_NOEXCEPT : multi_span(&data, bounds_type{1}) - { - static_assert(bounds_type::dynamic_rank > 0 || bounds_type::static_size == 0 || - bounds_type::static_size == 1, - "Construction from a single element only possible " - "for dynamic or fixed spans of length 0 or 1."); - } - - // prevent constructing from temporaries for single-elements - constexpr multi_span(value_type&&) = delete; - - // construct from pointer + length - constexpr multi_span(pointer ptr, size_type size) GSL_NOEXCEPT - : multi_span(ptr, bounds_type{size}) - { - } - - // construct from pointer + length - multidimensional - constexpr multi_span(pointer data, bounds_type bounds) GSL_NOEXCEPT : data_(data), - bounds_(std::move(bounds)) - { - Expects((bounds_.size() > 0 && data != nullptr) || bounds_.size() == 0); - } - - // construct from begin,end pointer pair - template ::value && - details::LessThan::value>> - constexpr multi_span(pointer begin, Ptr end) - : multi_span(begin, - details::newBoundsHelper(static_cast(end) - begin)) - { - Expects(begin != nullptr && end != nullptr && begin <= static_cast(end)); - } - - // construct from n-dimensions static array - template > - constexpr multi_span(T (&arr)[N]) - : multi_span(reinterpret_cast(arr), bounds_type{typename Helper::bounds_type{}}) - { - static_assert(std::is_convertible::value, - "Cannot convert from source type to target multi_span type."); - static_assert(std::is_convertible::value, - "Cannot construct a multi_span from an array with fewer elements."); - } - - // construct from n-dimensions dynamic array (e.g. new int[m][4]) - // (precedence will be lower than the 1-dimension pointer) - template > - constexpr multi_span(T* const& data, size_type size) - : multi_span(reinterpret_cast(data), typename Helper::bounds_type{size}) - { - static_assert(std::is_convertible::value, - "Cannot convert from source type to target multi_span type."); - } - - // construct from std::array - template - constexpr multi_span(std::array& arr) - : multi_span(arr.data(), bounds_type{static_bounds{}}) - { - static_assert( - std::is_convertible(*)[]>::value, - "Cannot convert from source type to target multi_span type."); - static_assert(std::is_convertible, bounds_type>::value, - "You cannot construct a multi_span from a std::array of smaller size."); - } - - // construct from const std::array - template - constexpr multi_span(const std::array& arr) - : multi_span(arr.data(), bounds_type{static_bounds{}}) - { - static_assert(std::is_convertible(*)[]>::value, - "Cannot convert from source type to target multi_span type."); - static_assert(std::is_convertible, bounds_type>::value, - "You cannot construct a multi_span from a std::array of smaller size."); - } - - // prevent constructing from temporary std::array - template - constexpr multi_span(std::array&& arr) = delete; - - // construct from containers - // future: could use contiguous_iterator_traits to identify only contiguous containers - // type-requirements: container must have .size(), operator[] which are value_type compatible - template ::value && - std::is_convertible::value && - std::is_same().size(), - *std::declval().data())>, - DataType>::value>> - constexpr multi_span(Cont& cont) - : multi_span(static_cast(cont.data()), - details::newBoundsHelper(narrow_cast(cont.size()))) - { - } - - // prevent constructing from temporary containers - template ::value && - std::is_convertible::value && - std::is_same().size(), - *std::declval().data())>, - DataType>::value>> - explicit constexpr multi_span(Cont&& cont) = delete; - - // construct from a convertible multi_span - template , - typename = std::enable_if_t::value && - std::is_convertible::value>> - constexpr multi_span(multi_span other) GSL_NOEXCEPT - : data_(other.data_), - bounds_(other.bounds_) - { - } - - // trivial copy and move - constexpr multi_span(const multi_span&) = default; - constexpr multi_span(multi_span&&) = default; - - // trivial assignment - constexpr multi_span& operator=(const multi_span&) = default; - constexpr multi_span& operator=(multi_span&&) = default; - - // first() - extract the first Count elements into a new multi_span - template - constexpr multi_span first() const GSL_NOEXCEPT - { - static_assert(Count >= 0, "Count must be >= 0."); - static_assert(bounds_type::static_size == dynamic_range || - Count <= bounds_type::static_size, - "Count is out of bounds."); - - Expects(bounds_type::static_size != dynamic_range || Count <= this->size()); - return {this->data(), Count}; - } - - // first() - extract the first count elements into a new multi_span - constexpr multi_span first(size_type count) const GSL_NOEXCEPT - { - Expects(count >= 0 && count <= this->size()); - return {this->data(), count}; - } - - // last() - extract the last Count elements into a new multi_span - template - constexpr multi_span last() const GSL_NOEXCEPT - { - static_assert(Count >= 0, "Count must be >= 0."); - static_assert(bounds_type::static_size == dynamic_range || - Count <= bounds_type::static_size, - "Count is out of bounds."); - - Expects(bounds_type::static_size != dynamic_range || Count <= this->size()); - return {this->data() + this->size() - Count, Count}; - } - - // last() - extract the last count elements into a new multi_span - constexpr multi_span last(size_type count) const GSL_NOEXCEPT - { - Expects(count >= 0 && count <= this->size()); - return {this->data() + this->size() - count, count}; - } - - // subspan() - create a subview of Count elements starting at Offset - template - constexpr multi_span subspan() const GSL_NOEXCEPT - { - static_assert(Count >= 0, "Count must be >= 0."); - static_assert(Offset >= 0, "Offset must be >= 0."); - static_assert(bounds_type::static_size == dynamic_range || - ((Offset <= bounds_type::static_size) && - Count <= bounds_type::static_size - Offset), - "You must describe a sub-range within bounds of the multi_span."); - - Expects(bounds_type::static_size != dynamic_range || - (Offset <= this->size() && Count <= this->size() - Offset)); - return {this->data() + Offset, Count}; - } - - // subspan() - create a subview of count elements starting at offset - // supplying dynamic_range for count will consume all available elements from offset - constexpr multi_span - subspan(size_type offset, size_type count = dynamic_range) const GSL_NOEXCEPT - { - Expects((offset >= 0 && offset <= this->size()) && - (count == dynamic_range || (count <= this->size() - offset))); - return {this->data() + offset, count == dynamic_range ? this->length() - offset : count}; - } - - // section - creates a non-contiguous, strided multi_span from a contiguous one - constexpr strided_span section(index_type origin, - index_type extents) const GSL_NOEXCEPT - { - size_type size = this->bounds().total_size() - this->bounds().linearize(origin); - return {&this->operator[](origin), size, - strided_bounds{extents, details::make_stride(bounds())}}; - } - - // length of the multi_span in elements - constexpr size_type size() const GSL_NOEXCEPT { return bounds_.size(); } - - // length of the multi_span in elements - constexpr size_type length() const GSL_NOEXCEPT { return this->size(); } - - // length of the multi_span in bytes - constexpr size_type size_bytes() const GSL_NOEXCEPT - { - return narrow_cast(sizeof(value_type)) * this->size(); - } - - // length of the multi_span in bytes - constexpr size_type length_bytes() const GSL_NOEXCEPT { return this->size_bytes(); } - - constexpr bool empty() const GSL_NOEXCEPT { return this->size() == 0; } - - static constexpr std::size_t rank() { return Rank; } - - template - constexpr size_type extent() const GSL_NOEXCEPT - { - static_assert(Dim < Rank, - "Dimension should be less than rank (dimension count starts from 0)."); - return bounds_.template extent(); - } - - template - constexpr size_type extent(IntType dim) const GSL_NOEXCEPT - { - return bounds_.extent(dim); - } - - constexpr bounds_type bounds() const GSL_NOEXCEPT { return bounds_; } - - constexpr pointer data() const GSL_NOEXCEPT { return data_; } - - template - constexpr reference operator()(FirstIndex idx) - { - return this->operator[](narrow_cast(idx)); - } - - template - constexpr reference operator()(FirstIndex firstIndex, OtherIndices... indices) - { - index_type idx = {narrow_cast(firstIndex), - narrow_cast(indices)...}; - return this->operator[](idx); - } - - constexpr reference operator[](const index_type& idx) const GSL_NOEXCEPT - { - return data_[bounds_.linearize(idx)]; - } - - template 1), typename Ret = std::enable_if_t> - constexpr Ret operator[](size_type idx) const GSL_NOEXCEPT - { - Expects(idx >= 0 && idx < bounds_.size()); // index is out of bounds of the array - const size_type ridx = idx * bounds_.stride(); - - // index is out of bounds of the underlying data - Expects(ridx < bounds_.total_size()); - return Ret{data_ + ridx, bounds_.slice()}; - } - - constexpr iterator begin() const GSL_NOEXCEPT { return iterator{this, true}; } - - constexpr iterator end() const GSL_NOEXCEPT { return iterator{this, false}; } - - constexpr const_iterator cbegin() const GSL_NOEXCEPT - { - return const_iterator{reinterpret_cast(this), true}; - } - - constexpr const_iterator cend() const GSL_NOEXCEPT - { - return const_iterator{reinterpret_cast(this), false}; - } - - constexpr reverse_iterator rbegin() const GSL_NOEXCEPT { return reverse_iterator{end()}; } - - constexpr reverse_iterator rend() const GSL_NOEXCEPT { return reverse_iterator{begin()}; } - - constexpr const_reverse_iterator crbegin() const GSL_NOEXCEPT - { - return const_reverse_iterator{cend()}; - } - - constexpr const_reverse_iterator crend() const GSL_NOEXCEPT - { - return const_reverse_iterator{cbegin()}; - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator==(const multi_span& other) const GSL_NOEXCEPT - { - return bounds_.size() == other.bounds_.size() && - (data_ == other.data_ || std::equal(this->begin(), this->end(), other.begin())); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator!=(const multi_span& other) const GSL_NOEXCEPT - { - return !(*this == other); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator<(const multi_span& other) const GSL_NOEXCEPT - { - return std::lexicographical_compare(this->begin(), this->end(), other.begin(), other.end()); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator<=(const multi_span& other) const GSL_NOEXCEPT - { - return !(other < *this); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator>(const multi_span& other) const GSL_NOEXCEPT - { - return (other < *this); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator>=(const multi_span& other) const GSL_NOEXCEPT - { - return !(*this < other); - } -}; - -// -// Free functions for manipulating spans -// - -// reshape a multi_span into a different dimensionality -// DimCount and Enabled here are workarounds for a bug in MSVC 2015 -template 0), typename = std::enable_if_t> -constexpr auto as_multi_span(SpanType s, Dimensions2... dims) - -> multi_span -{ - static_assert(details::is_multi_span::value, - "Variadic as_multi_span() is for reshaping existing spans."); - using BoundsType = - typename multi_span::bounds_type; - auto tobounds = details::static_as_multi_span_helper(dims..., details::Sep{}); - details::verifyBoundsReshape(s.bounds(), tobounds); - return {s.data(), tobounds}; -} - -// convert a multi_span to a multi_span -template -multi_span as_bytes(multi_span s) GSL_NOEXCEPT -{ - static_assert(std::is_trivial>::value, - "The value_type of multi_span must be a trivial type."); - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -// convert a multi_span to a multi_span (a writeable byte multi_span) -// this is not currently a portable function that can be relied upon to work -// on all implementations. It should be considered an experimental extension -// to the standard GSL interface. -template -multi_span as_writeable_bytes(multi_span s) GSL_NOEXCEPT -{ - static_assert(std::is_trivial>::value, - "The value_type of multi_span must be a trivial type."); - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -// convert a multi_span to a multi_span -// this is not currently a portable function that can be relied upon to work -// on all implementations. It should be considered an experimental extension -// to the standard GSL interface. -template -constexpr auto -as_multi_span(multi_span s) GSL_NOEXCEPT -> multi_span< - const U, static_cast( - multi_span::bounds_type::static_size != dynamic_range - ? (static_cast( - multi_span::bounds_type::static_size) / - sizeof(U)) - : dynamic_range)> -{ - using ConstByteSpan = multi_span; - static_assert( - std::is_trivial>::value && - (ConstByteSpan::bounds_type::static_size == dynamic_range || - ConstByteSpan::bounds_type::static_size % narrow_cast(sizeof(U)) == 0), - "Target type must be a trivial type and its size must match the byte array size"); - - Expects((s.size_bytes() % narrow_cast(sizeof(U))) == 0 && - (s.size_bytes() / narrow_cast(sizeof(U))) < PTRDIFF_MAX); - return {reinterpret_cast(s.data()), - s.size_bytes() / narrow_cast(sizeof(U))}; -} - -// convert a multi_span to a multi_span -// this is not currently a portable function that can be relied upon to work -// on all implementations. It should be considered an experimental extension -// to the standard GSL interface. -template -constexpr auto as_multi_span(multi_span s) GSL_NOEXCEPT - -> multi_span( - multi_span::bounds_type::static_size != dynamic_range - ? static_cast( - multi_span::bounds_type::static_size) / - sizeof(U) - : dynamic_range)> -{ - using ByteSpan = multi_span; - static_assert( - std::is_trivial>::value && - (ByteSpan::bounds_type::static_size == dynamic_range || - ByteSpan::bounds_type::static_size % static_cast(sizeof(U)) == 0), - "Target type must be a trivial type and its size must match the byte array size"); - - Expects((s.size_bytes() % sizeof(U)) == 0); - return {reinterpret_cast(s.data()), - s.size_bytes() / narrow_cast(sizeof(U))}; -} - -template -constexpr auto as_multi_span(T* const& ptr, dim_t... args) - -> multi_span, Dimensions...> -{ - return {reinterpret_cast*>(ptr), - details::static_as_multi_span_helper>(args..., - details::Sep{})}; -} - -template -constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) -> - typename details::SpanArrayTraits::type -{ - return {reinterpret_cast*>(arr), len}; -} - -template -constexpr auto as_multi_span(T (&arr)[N]) -> typename details::SpanArrayTraits::type -{ - return {arr}; -} - -template -constexpr multi_span as_multi_span(const std::array& arr) -{ - return {arr}; -} - -template -constexpr multi_span as_multi_span(const std::array&&) = delete; - -template -constexpr multi_span as_multi_span(std::array& arr) -{ - return {arr}; -} - -template -constexpr multi_span as_multi_span(T* begin, T* end) -{ - return {begin, end}; -} - -template -constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t< - !details::is_multi_span>::value, - multi_span, dynamic_range>> -{ - Expects(arr.size() < PTRDIFF_MAX); - return {arr.data(), narrow_cast(arr.size())}; -} - -template -constexpr auto as_multi_span(Cont&& arr) -> std::enable_if_t< - !details::is_multi_span>::value, - multi_span, dynamic_range>> = delete; - -// from basic_string which doesn't have nonconst .data() member like other contiguous containers -template -constexpr auto as_multi_span(std::basic_string& str) - -> multi_span -{ - Expects(str.size() < PTRDIFF_MAX); - return {&str[0], narrow_cast(str.size())}; -} - -// strided_span is an extension that is not strictly part of the GSL at this time. -// It is kept here while the multidimensional interface is still being defined. -template -class strided_span -{ -public: - using bounds_type = strided_bounds; - using size_type = typename bounds_type::size_type; - using index_type = typename bounds_type::index_type; - using value_type = ValueType; - using const_value_type = std::add_const_t; - using pointer = std::add_pointer_t; - using reference = std::add_lvalue_reference_t; - using iterator = general_span_iterator; - using const_strided_span = strided_span; - using const_iterator = general_span_iterator; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - using sliced_type = - std::conditional_t>; - -private: - pointer data_; - bounds_type bounds_; - - friend iterator; - friend const_iterator; - template - friend class strided_span; - -public: - // from raw data - constexpr strided_span(pointer ptr, size_type size, bounds_type bounds) - : data_(ptr), bounds_(std::move(bounds)) - { - Expects((bounds_.size() > 0 && ptr != nullptr) || bounds_.size() == 0); - // Bounds cross data boundaries - Expects(this->bounds().total_size() <= size); - (void) size; - } - - // from static array of size N - template - constexpr strided_span(value_type (&values)[N], bounds_type bounds) - : strided_span(values, N, std::move(bounds)) - { - } - - // from array view - template ::value, - typename = std::enable_if_t> - constexpr strided_span(multi_span av, bounds_type bounds) - : strided_span(av.data(), av.bounds().total_size(), std::move(bounds)) - { - } - - // convertible - template ::value>> - constexpr strided_span(const strided_span& other) - : data_(other.data_), bounds_(other.bounds_) - { - } - - // convert from bytes - template - constexpr strided_span< - typename std::enable_if::value, OtherValueType>::type, - Rank> - as_strided_span() const - { - static_assert((sizeof(OtherValueType) >= sizeof(value_type)) && - (sizeof(OtherValueType) % sizeof(value_type) == 0), - "OtherValueType should have a size to contain a multiple of ValueTypes"); - auto d = narrow_cast(sizeof(OtherValueType) / sizeof(value_type)); - - size_type size = this->bounds().total_size() / d; - return {const_cast(reinterpret_cast(this->data())), - size, - bounds_type{resize_extent(this->bounds().index_bounds(), d), - resize_stride(this->bounds().strides(), d)}}; - } - - constexpr strided_span section(index_type origin, index_type extents) const - { - size_type size = this->bounds().total_size() - this->bounds().linearize(origin); - return {&this->operator[](origin), size, - bounds_type{extents, details::make_stride(bounds())}}; - } - - constexpr reference operator[](const index_type& idx) const - { - return data_[bounds_.linearize(idx)]; - } - - template 1), typename Ret = std::enable_if_t> - constexpr Ret operator[](size_type idx) const - { - Expects(idx < bounds_.size()); // index is out of bounds of the array - const size_type ridx = idx * bounds_.stride(); - - // index is out of bounds of the underlying data - Expects(ridx < bounds_.total_size()); - return {data_ + ridx, bounds_.slice().total_size(), bounds_.slice()}; - } - - constexpr bounds_type bounds() const GSL_NOEXCEPT { return bounds_; } - - template - constexpr size_type extent() const GSL_NOEXCEPT - { - static_assert(Dim < Rank, - "dimension should be less than Rank (dimension count starts from 0)"); - return bounds_.template extent(); - } - - constexpr size_type size() const GSL_NOEXCEPT { return bounds_.size(); } - - constexpr pointer data() const GSL_NOEXCEPT { return data_; } - - constexpr explicit operator bool() const GSL_NOEXCEPT { return data_ != nullptr; } - - constexpr iterator begin() const { return iterator{this, true}; } - - constexpr iterator end() const { return iterator{this, false}; } - - constexpr const_iterator cbegin() const - { - return const_iterator{reinterpret_cast(this), true}; - } - - constexpr const_iterator cend() const - { - return const_iterator{reinterpret_cast(this), false}; - } - - constexpr reverse_iterator rbegin() const { return reverse_iterator{end()}; } - - constexpr reverse_iterator rend() const { return reverse_iterator{begin()}; } - - constexpr const_reverse_iterator crbegin() const { return const_reverse_iterator{cend()}; } - - constexpr const_reverse_iterator crend() const { return const_reverse_iterator{cbegin()}; } - - template , std::remove_cv_t>::value>> - constexpr bool - operator==(const strided_span& other) const GSL_NOEXCEPT - { - return bounds_.size() == other.bounds_.size() && - (data_ == other.data_ || std::equal(this->begin(), this->end(), other.begin())); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator!=(const strided_span& other) const GSL_NOEXCEPT - { - return !(*this == other); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator<(const strided_span& other) const GSL_NOEXCEPT - { - return std::lexicographical_compare(this->begin(), this->end(), other.begin(), other.end()); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator<=(const strided_span& other) const GSL_NOEXCEPT - { - return !(other < *this); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator>(const strided_span& other) const GSL_NOEXCEPT - { - return (other < *this); - } - - template , std::remove_cv_t>::value>> - constexpr bool - operator>=(const strided_span& other) const GSL_NOEXCEPT - { - return !(*this < other); - } - -private: - static index_type resize_extent(const index_type& extent, std::ptrdiff_t d) - { - // The last dimension of the array needs to contain a multiple of new type elements - Expects(extent[Rank - 1] >= d && (extent[Rank - 1] % d == 0)); - - index_type ret = extent; - ret[Rank - 1] /= d; - - return ret; - } - - template > - static index_type resize_stride(const index_type& strides, std::ptrdiff_t, void* = nullptr) - { - // Only strided arrays with regular strides can be resized - Expects(strides[Rank - 1] == 1); - - return strides; - } - - template 1), typename = std::enable_if_t> - static index_type resize_stride(const index_type& strides, std::ptrdiff_t d) - { - // Only strided arrays with regular strides can be resized - Expects(strides[Rank - 1] == 1); - // The strides must have contiguous chunks of - // memory that can contain a multiple of new type elements - Expects(strides[Rank - 2] >= d && (strides[Rank - 2] % d == 0)); - - for (std::size_t i = Rank - 1; i > 0; --i) { - // Only strided arrays with regular strides can be resized - Expects((strides[i - 1] >= strides[i]) && (strides[i - 1] % strides[i] == 0)); - } - - index_type ret = strides / d; - ret[Rank - 1] = 1; - - return ret; - } -}; - -template -class contiguous_span_iterator -{ -public: - using iterator_category = std::random_access_iterator_tag; - using value_type = typename Span::value_type; - using difference_type = std::ptrdiff_t; - using pointer = value_type*; - using reference = value_type&; - -private: - template - friend class multi_span; - - pointer data_; - const Span* m_validator; - void validateThis() const - { - // iterator is out of range of the array - Expects(data_ >= m_validator->data_ && data_ < m_validator->data_ + m_validator->size()); - } - contiguous_span_iterator(const Span* container, bool isbegin) - : data_(isbegin ? container->data_ : container->data_ + container->size()) - , m_validator(container) - { - } - -public: - reference operator*() const GSL_NOEXCEPT - { - validateThis(); - return *data_; - } - pointer operator->() const GSL_NOEXCEPT - { - validateThis(); - return data_; - } - contiguous_span_iterator& operator++() GSL_NOEXCEPT - { - ++data_; - return *this; - } - contiguous_span_iterator operator++(int) GSL_NOEXCEPT - { - auto ret = *this; - ++(*this); - return ret; - } - contiguous_span_iterator& operator--() GSL_NOEXCEPT - { - --data_; - return *this; - } - contiguous_span_iterator operator--(int) GSL_NOEXCEPT - { - auto ret = *this; - --(*this); - return ret; - } - contiguous_span_iterator operator+(difference_type n) const GSL_NOEXCEPT - { - contiguous_span_iterator ret{*this}; - return ret += n; - } - contiguous_span_iterator& operator+=(difference_type n) GSL_NOEXCEPT - { - data_ += n; - return *this; - } - contiguous_span_iterator operator-(difference_type n) const GSL_NOEXCEPT - { - contiguous_span_iterator ret{*this}; - return ret -= n; - } - contiguous_span_iterator& operator-=(difference_type n) GSL_NOEXCEPT { return *this += -n; } - difference_type operator-(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT - { - Expects(m_validator == rhs.m_validator); - return data_ - rhs.data_; - } - reference operator[](difference_type n) const GSL_NOEXCEPT { return *(*this + n); } - bool operator==(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT - { - Expects(m_validator == rhs.m_validator); - return data_ == rhs.data_; - } - bool operator!=(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT - { - return !(*this == rhs); - } - bool operator<(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT - { - Expects(m_validator == rhs.m_validator); - return data_ < rhs.data_; - } - bool operator<=(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT - { - return !(rhs < *this); - } - bool operator>(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT { return rhs < *this; } - bool operator>=(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT - { - return !(rhs > *this); - } - void swap(contiguous_span_iterator& rhs) GSL_NOEXCEPT - { - std::swap(data_, rhs.data_); - std::swap(m_validator, rhs.m_validator); - } -}; - -template -contiguous_span_iterator operator+(typename contiguous_span_iterator::difference_type n, - const contiguous_span_iterator& rhs) GSL_NOEXCEPT -{ - return rhs + n; -} - -template -class general_span_iterator -{ -public: - using iterator_category = std::random_access_iterator_tag; - using value_type = typename Span::value_type; - using difference_type = std::ptrdiff_t; - using pointer = value_type*; - using reference = value_type&; - -private: - template - friend class strided_span; - - const Span* m_container; - typename Span::bounds_type::iterator m_itr; - general_span_iterator(const Span* container, bool isbegin) - : m_container(container) - , m_itr(isbegin ? m_container->bounds().begin() : m_container->bounds().end()) - { - } - -public: - reference operator*() GSL_NOEXCEPT { return (*m_container)[*m_itr]; } - pointer operator->() GSL_NOEXCEPT { return &(*m_container)[*m_itr]; } - general_span_iterator& operator++() GSL_NOEXCEPT - { - ++m_itr; - return *this; - } - general_span_iterator operator++(int) GSL_NOEXCEPT - { - auto ret = *this; - ++(*this); - return ret; - } - general_span_iterator& operator--() GSL_NOEXCEPT - { - --m_itr; - return *this; - } - general_span_iterator operator--(int) GSL_NOEXCEPT - { - auto ret = *this; - --(*this); - return ret; - } - general_span_iterator operator+(difference_type n) const GSL_NOEXCEPT - { - general_span_iterator ret{*this}; - return ret += n; - } - general_span_iterator& operator+=(difference_type n) GSL_NOEXCEPT - { - m_itr += n; - return *this; - } - general_span_iterator operator-(difference_type n) const GSL_NOEXCEPT - { - general_span_iterator ret{*this}; - return ret -= n; - } - general_span_iterator& operator-=(difference_type n) GSL_NOEXCEPT { return *this += -n; } - difference_type operator-(const general_span_iterator& rhs) const GSL_NOEXCEPT - { - Expects(m_container == rhs.m_container); - return m_itr - rhs.m_itr; - } - value_type operator[](difference_type n) const GSL_NOEXCEPT { return (*m_container)[m_itr[n]]; } - - bool operator==(const general_span_iterator& rhs) const GSL_NOEXCEPT - { - Expects(m_container == rhs.m_container); - return m_itr == rhs.m_itr; - } - bool operator!=(const general_span_iterator& rhs) const GSL_NOEXCEPT { return !(*this == rhs); } - bool operator<(const general_span_iterator& rhs) const GSL_NOEXCEPT - { - Expects(m_container == rhs.m_container); - return m_itr < rhs.m_itr; - } - bool operator<=(const general_span_iterator& rhs) const GSL_NOEXCEPT { return !(rhs < *this); } - bool operator>(const general_span_iterator& rhs) const GSL_NOEXCEPT { return rhs < *this; } - bool operator>=(const general_span_iterator& rhs) const GSL_NOEXCEPT { return !(rhs > *this); } - void swap(general_span_iterator& rhs) GSL_NOEXCEPT - { - std::swap(m_itr, rhs.m_itr); - std::swap(m_container, rhs.m_container); - } -}; - -template -general_span_iterator operator+(typename general_span_iterator::difference_type n, - const general_span_iterator& rhs) GSL_NOEXCEPT -{ - return rhs + n; -} - -} // namespace gsl - -#undef GSL_NOEXCEPT - -#ifdef _MSC_VER -#if _MSC_VER < 1910 - -#undef constexpr -#pragma pop_macro("constexpr") -#endif // _MSC_VER < 1910 - -#pragma warning(pop) - -#endif // _MSC_VER - -#if __GNUC__ > 6 -#pragma GCC diagnostic pop -#endif // __GNUC__ > 6 - -#endif // GSL_MULTI_SPAN_H diff --git a/inst/include/gsl/pointers b/inst/include/gsl/pointers deleted file mode 100644 index 69499d6..0000000 --- a/inst/include/gsl/pointers +++ /dev/null @@ -1,193 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GSL_POINTERS_H -#define GSL_POINTERS_H - -#include // for Ensures, Expects - -#include // for forward -#include // for ptrdiff_t, nullptr_t, ostream, size_t -#include // for shared_ptr, unique_ptr -#include // for hash -#include // for enable_if_t, is_convertible, is_assignable - -#if defined(_MSC_VER) && _MSC_VER < 1910 -#pragma push_macro("constexpr") -#define constexpr /*constexpr*/ - -#endif // defined(_MSC_VER) && _MSC_VER < 1910 - -namespace gsl -{ - -// -// GSL.owner: ownership pointers -// -using std::unique_ptr; -using std::shared_ptr; - -// -// owner -// -// owner is designed as a bridge for code that must deal directly with owning pointers for some reason -// -// T must be a pointer type -// - disallow construction from any type other than pointer type -// -template ::value>> -using owner = T; - -// -// not_null -// -// Restricts a pointer or smart pointer to only hold non-null values. -// -// Has zero size overhead over T. -// -// If T is a pointer (i.e. T == U*) then -// - allow construction from U* -// - disallow construction from nullptr_t -// - disallow default construction -// - ensure construction from null U* fails -// - allow implicit conversion to U* -// -template -class not_null -{ -public: - static_assert(std::is_assignable::value, "T cannot be assigned nullptr."); - - template ::value>> - constexpr explicit not_null(U&& u) : ptr_(std::forward(u)) - { - Expects(ptr_ != nullptr); - } - - template ::value>> - constexpr explicit not_null(T u) : ptr_(u) - { - Expects(ptr_ != nullptr); - } - - template ::value>> - constexpr not_null(const not_null& other) : not_null(other.get()) - { - } - - not_null(not_null&& other) = default; - not_null(const not_null& other) = default; - not_null& operator=(const not_null& other) = default; - - constexpr T get() const - { - Ensures(ptr_ != nullptr); - return ptr_; - } - - constexpr operator T() const { return get(); } - constexpr T operator->() const { return get(); } - constexpr decltype(auto) operator*() const { return *get(); } - - // prevents compilation when someone attempts to assign a null pointer constant - not_null(std::nullptr_t) = delete; - not_null& operator=(std::nullptr_t) = delete; - - // unwanted operators...pointers only point to single objects! - not_null& operator++() = delete; - not_null& operator--() = delete; - not_null operator++(int) = delete; - not_null operator--(int) = delete; - not_null& operator+=(std::ptrdiff_t) = delete; - not_null& operator-=(std::ptrdiff_t) = delete; - void operator[](std::ptrdiff_t) const = delete; - -private: - T ptr_; -}; - -template -std::ostream& operator<<(std::ostream& os, const not_null& val) -{ - os << val.get(); - return os; -} - -template -auto operator==(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() == rhs.get()) -{ - return lhs.get() == rhs.get(); -} - -template -auto operator!=(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() != rhs.get()) -{ - return lhs.get() != rhs.get(); -} - -template -auto operator<(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() < rhs.get()) -{ - return lhs.get() < rhs.get(); -} - -template -auto operator<=(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() <= rhs.get()) -{ - return lhs.get() <= rhs.get(); -} - -template -auto operator>(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() > rhs.get()) -{ - return lhs.get() > rhs.get(); -} - -template -auto operator>=(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() >= rhs.get()) -{ - return lhs.get() >= rhs.get(); -} - -// more unwanted operators -template -std::ptrdiff_t operator-(const not_null&, const not_null&) = delete; -template -not_null operator-(const not_null&, std::ptrdiff_t) = delete; -template -not_null operator+(const not_null&, std::ptrdiff_t) = delete; -template -not_null operator+(std::ptrdiff_t, const not_null&) = delete; - -} // namespace gsl - -namespace std -{ -template -struct hash> -{ - std::size_t operator()(const gsl::not_null& value) const { return hash{}(value); } -}; - -} // namespace std - -#if defined(_MSC_VER) && _MSC_VER < 1910 -#undef constexpr -#pragma pop_macro("constexpr") - -#endif // defined(_MSC_VER) && _MSC_VER < 1910 - -#endif // GSL_POINTERS_H diff --git a/inst/include/gsl/span b/inst/include/gsl/span deleted file mode 100644 index 2fa9cc5..0000000 --- a/inst/include/gsl/span +++ /dev/null @@ -1,766 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GSL_SPAN_H -#define GSL_SPAN_H - -#include // for Expects -#include // for byte -#include // for narrow_cast, narrow - -#include // for lexicographical_compare -#include // for array -#include // for ptrdiff_t, size_t, nullptr_t -#include // for reverse_iterator, distance, random_access_... -#include -#include -#include // for enable_if_t, declval, is_convertible, inte... -#include - -#ifdef _MSC_VER -#pragma warning(push) - -// turn off some warnings that are noisy about our Expects statements -#pragma warning(disable : 4127) // conditional expression is constant -#pragma warning(disable : 4702) // unreachable code - -// blanket turn off warnings from CppCoreCheck for now -// so people aren't annoyed by them when running the tool. -// more targeted suppressions will be added in a future update to the GSL -#pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495) - -#if _MSC_VER < 1910 -#pragma push_macro("constexpr") -#define constexpr /*constexpr*/ -#define GSL_USE_STATIC_CONSTEXPR_WORKAROUND - -#endif // _MSC_VER < 1910 -#else // _MSC_VER - -// See if we have enough C++17 power to use a static constexpr data member -// without needing an out-of-line definition -#if !(defined(__cplusplus) && (__cplusplus >= 201703L)) -#define GSL_USE_STATIC_CONSTEXPR_WORKAROUND -#endif // !(defined(__cplusplus) && (__cplusplus >= 201703L)) - -#endif // _MSC_VER - -// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t) -// While there is a conversion from signed to unsigned, it happens at -// compiletime, so the compiler wouldn't have to warn indiscriminently, but -// could check if the source value actually doesn't fit into the target type -// and only warn in those cases. -#if __GNUC__ > 6 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-conversion" -#endif - -namespace gsl -{ - -// [views.constants], constants -constexpr const std::ptrdiff_t dynamic_extent = -1; - -template -class span; - -// implementation details -namespace details -{ - template - struct is_span_oracle : std::false_type - { - }; - - template - struct is_span_oracle> : std::true_type - { - }; - - template - struct is_span : public is_span_oracle> - { - }; - - template - struct is_std_array_oracle : std::false_type - { - }; - - template - struct is_std_array_oracle> : std::true_type - { - }; - - template - struct is_std_array : public is_std_array_oracle> - { - }; - - template - struct is_allowed_extent_conversion - : public std::integral_constant - { - }; - - template - struct is_allowed_element_type_conversion - : public std::integral_constant::value> - { - }; - - template - class span_iterator - { - using element_type_ = typename Span::element_type; - - public: - -#ifdef _MSC_VER - // Tell Microsoft standard library that span_iterators are checked. - using _Unchecked_type = typename Span::pointer; -#endif - - using iterator_category = std::random_access_iterator_tag; - using value_type = std::remove_cv_t; - using difference_type = typename Span::index_type; - - using reference = std::conditional_t&; - using pointer = std::add_pointer_t; - - span_iterator() = default; - - constexpr span_iterator(const Span* span, typename Span::index_type idx) noexcept - : span_(span), index_(idx) - {} - - friend span_iterator; - template* = nullptr> - constexpr span_iterator(const span_iterator& other) noexcept - : span_iterator(other.span_, other.index_) - { - } - - constexpr reference operator*() const - { - Expects(index_ != span_->size()); - return *(span_->data() + index_); - } - - constexpr pointer operator->() const - { - Expects(index_ != span_->size()); - return span_->data() + index_; - } - - constexpr span_iterator& operator++() - { - Expects(0 <= index_ && index_ != span_->size()); - ++index_; - return *this; - } - - constexpr span_iterator operator++(int) - { - auto ret = *this; - ++(*this); - return ret; - } - - constexpr span_iterator& operator--() - { - Expects(index_ != 0 && index_ <= span_->size()); - --index_; - return *this; - } - - constexpr span_iterator operator--(int) - { - auto ret = *this; - --(*this); - return ret; - } - - constexpr span_iterator operator+(difference_type n) const - { - auto ret = *this; - return ret += n; - } - - friend constexpr span_iterator operator+(difference_type n, span_iterator const& rhs) - { - return rhs + n; - } - - constexpr span_iterator& operator+=(difference_type n) - { - Expects((index_ + n) >= 0 && (index_ + n) <= span_->size()); - index_ += n; - return *this; - } - - constexpr span_iterator operator-(difference_type n) const - { - auto ret = *this; - return ret -= n; - } - - constexpr span_iterator& operator-=(difference_type n) { return *this += -n; } - - constexpr difference_type operator-(span_iterator rhs) const - { - Expects(span_ == rhs.span_); - return index_ - rhs.index_; - } - - constexpr reference operator[](difference_type n) const - { - return *(*this + n); - } - - constexpr friend bool operator==(span_iterator lhs, - span_iterator rhs) noexcept - { - return lhs.span_ == rhs.span_ && lhs.index_ == rhs.index_; - } - - constexpr friend bool operator!=(span_iterator lhs, - span_iterator rhs) noexcept - { - return !(lhs == rhs); - } - - constexpr friend bool operator<(span_iterator lhs, - span_iterator rhs) noexcept - { - return lhs.index_ < rhs.index_; - } - - constexpr friend bool operator<=(span_iterator lhs, - span_iterator rhs) noexcept - { - return !(rhs < lhs); - } - - constexpr friend bool operator>(span_iterator lhs, - span_iterator rhs) noexcept - { - return rhs < lhs; - } - - constexpr friend bool operator>=(span_iterator lhs, - span_iterator rhs) noexcept - { - return !(rhs > lhs); - } - -#ifdef _MSC_VER - // MSVC++ iterator debugging support; allows STL algorithms in 15.8+ - // to unwrap span_iterator to a pointer type after a range check in STL - // algorithm calls - friend constexpr void _Verify_range(span_iterator lhs, - span_iterator rhs) noexcept - { // test that [lhs, rhs) forms a valid range inside an STL algorithm - Expects(lhs.span_ == rhs.span_ // range spans have to match - && lhs.index_ <= rhs.index_); // range must not be transposed - } - - constexpr void _Verify_offset(const difference_type n) const noexcept - { // test that the iterator *this + n is a valid range in an STL - // algorithm call - Expects((index_ + n) >= 0 && (index_ + n) <= span_->size()); - } - - constexpr pointer _Unwrapped() const noexcept - { // after seeking *this to a high water mark, or using one of the - // _Verify_xxx functions above, unwrap this span_iterator to a raw - // pointer - return span_->data() + index_; - } - - // Tell the STL that span_iterator should not be unwrapped if it can't - // validate in advance, even in release / optimized builds: -#if defined(GSL_USE_STATIC_CONSTEXPR_WORKAROUND) - static constexpr const bool _Unwrap_when_unverified = false; -#else - static constexpr bool _Unwrap_when_unverified = false; -#endif - constexpr void _Seek_to(const pointer p) noexcept - { // adjust the position of *this to previously verified location p - // after _Unwrapped - index_ = p - span_->data(); - } -#endif - - protected: - const Span* span_ = nullptr; - std::ptrdiff_t index_ = 0; - }; - - template - class extent_type - { - public: - using index_type = std::ptrdiff_t; - - static_assert(Ext >= 0, "A fixed-size span must be >= 0 in size."); - - constexpr extent_type() noexcept {} - - template - constexpr extent_type(extent_type ext) - { - static_assert(Other == Ext || Other == dynamic_extent, - "Mismatch between fixed-size extent and size of initializing data."); - Expects(ext.size() == Ext); - } - - constexpr extent_type(index_type size) { Expects(size == Ext); } - - constexpr index_type size() const noexcept { return Ext; } - }; - - template <> - class extent_type - { - public: - using index_type = std::ptrdiff_t; - - template - explicit constexpr extent_type(extent_type ext) : size_(ext.size()) - { - } - - explicit constexpr extent_type(index_type size) : size_(size) { Expects(size >= 0); } - - constexpr index_type size() const noexcept { return size_; } - - private: - index_type size_; - }; - - template - struct calculate_subspan_type - { - using type = span; - }; -} // namespace details - -// [span], class template span -template -class span -{ -public: - // constants and types - using element_type = ElementType; - using value_type = std::remove_cv_t; - using index_type = std::ptrdiff_t; - using pointer = element_type*; - using reference = element_type&; - - using iterator = details::span_iterator, false>; - using const_iterator = details::span_iterator, true>; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - - using size_type = index_type; - -#if defined(GSL_USE_STATIC_CONSTEXPR_WORKAROUND) - static constexpr const index_type extent { Extent }; -#else - static constexpr index_type extent { Extent }; -#endif - - // [span.cons], span constructors, copy, assignment, and destructor - template " SFINAE, - // since "std::enable_if_t" is ill-formed when Extent is greater than 0. - class = std::enable_if_t<(Dependent || Extent <= 0)>> - constexpr span() noexcept : storage_(nullptr, details::extent_type<0>()) - { - } - - constexpr span(pointer ptr, index_type count) : storage_(ptr, count) {} - - constexpr span(pointer firstElem, pointer lastElem) - : storage_(firstElem, std::distance(firstElem, lastElem)) - { - } - - template - constexpr span(element_type (&arr)[N]) noexcept - : storage_(KnownNotNull{&arr[0]}, details::extent_type()) - { - } - - template > - constexpr span(std::array& arr) noexcept - : storage_(&arr[0], details::extent_type()) - { - } - - template - constexpr span(const std::array, N>& arr) noexcept - : storage_(&arr[0], details::extent_type()) - { - } - - // NB: the SFINAE here uses .data() as a incomplete/imperfect proxy for the requirement - // on Container to be a contiguous sequence container. - template ::value && !details::is_std_array::value && - std::is_convertible::value && - std::is_convertible().data())>::value>> - constexpr span(Container& cont) : span(cont.data(), narrow(cont.size())) - { - } - - template ::value && !details::is_span::value && - std::is_convertible::value && - std::is_convertible().data())>::value>> - constexpr span(const Container& cont) : span(cont.data(), narrow(cont.size())) - { - } - - constexpr span(const span& other) noexcept = default; - - template < - class OtherElementType, std::ptrdiff_t OtherExtent, - class = std::enable_if_t< - details::is_allowed_extent_conversion::value && - details::is_allowed_element_type_conversion::value>> - constexpr span(const span& other) - : storage_(other.data(), details::extent_type(other.size())) - { - } - - ~span() noexcept = default; - constexpr span& operator=(const span& other) noexcept = default; - - // [span.sub], span subviews - template - constexpr span first() const - { - Expects(Count >= 0 && Count <= size()); - return {data(), Count}; - } - - template - constexpr span last() const - { - Expects(Count >= 0 && size() - Count >= 0); - return {data() + (size() - Count), Count}; - } - - template - constexpr auto subspan() const -> typename details::calculate_subspan_type::type - { - Expects((Offset >= 0 && size() - Offset >= 0) && - (Count == dynamic_extent || (Count >= 0 && Offset + Count <= size()))); - - return {data() + Offset, Count == dynamic_extent ? size() - Offset : Count}; - } - - constexpr span first(index_type count) const - { - Expects(count >= 0 && count <= size()); - return {data(), count}; - } - - constexpr span last(index_type count) const - { - return make_subspan(size() - count, dynamic_extent, subspan_selector{}); - } - - constexpr span subspan(index_type offset, - index_type count = dynamic_extent) const - { - return make_subspan(offset, count, subspan_selector{}); - } - - - // [span.obs], span observers - constexpr index_type size() const noexcept { return storage_.size(); } - constexpr index_type size_bytes() const noexcept - { - return size() * narrow_cast(sizeof(element_type)); - } - constexpr bool empty() const noexcept { return size() == 0; } - - // [span.elem], span element access - constexpr reference operator[](index_type idx) const - { - Expects(idx >= 0 && idx < storage_.size()); - return data()[idx]; - } - - constexpr reference at(index_type idx) const { return this->operator[](idx); } - constexpr reference operator()(index_type idx) const { return this->operator[](idx); } - constexpr pointer data() const noexcept { return storage_.data(); } - - // [span.iter], span iterator support - constexpr iterator begin() const noexcept { return {this, 0}; } - constexpr iterator end() const noexcept { return {this, size()}; } - - constexpr const_iterator cbegin() const noexcept { return {this, 0}; } - constexpr const_iterator cend() const noexcept { return {this, size()}; } - - constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator{end()}; } - constexpr reverse_iterator rend() const noexcept { return reverse_iterator{begin()}; } - - constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator{cend()}; } - constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator{cbegin()}; } - -#ifdef _MSC_VER - // Tell MSVC how to unwrap spans in range-based-for - constexpr pointer _Unchecked_begin() const noexcept { return data(); } - constexpr pointer _Unchecked_end() const noexcept { return data() + size(); } -#endif // _MSC_VER - -private: - - // Needed to remove unnecessary null check in subspans - struct KnownNotNull - { - pointer p; - }; - - // this implementation detail class lets us take advantage of the - // empty base class optimization to pay for only storage of a single - // pointer in the case of fixed-size spans - template - class storage_type : public ExtentType - { - public: - // KnownNotNull parameter is needed to remove unnecessary null check - // in subspans and constructors from arrays - template - constexpr storage_type(KnownNotNull data, OtherExtentType ext) : ExtentType(ext), data_(data.p) - { - Expects(ExtentType::size() >= 0); - } - - - template - constexpr storage_type(pointer data, OtherExtentType ext) : ExtentType(ext), data_(data) - { - Expects(ExtentType::size() >= 0); - Expects(data || ExtentType::size() == 0); - } - - constexpr pointer data() const noexcept { return data_; } - - private: - pointer data_; - }; - - storage_type> storage_; - - // The rest is needed to remove unnecessary null check - // in subspans and constructors from arrays - constexpr span(KnownNotNull ptr, index_type count) : storage_(ptr, count) {} - - template - class subspan_selector {}; - - template - span make_subspan(index_type offset, - index_type count, - subspan_selector) const - { - span tmp(*this); - return tmp.subspan(offset, count); - } - - span make_subspan(index_type offset, - index_type count, - subspan_selector) const - { - Expects(offset >= 0 && size() - offset >= 0); - if (count == dynamic_extent) - { - return { KnownNotNull{ data() + offset }, size() - offset }; - } - - Expects(count >= 0 && size() - offset >= count); - return { KnownNotNull{ data() + offset }, count }; - } -}; - -#if defined(GSL_USE_STATIC_CONSTEXPR_WORKAROUND) -template -constexpr const typename span::index_type span::extent; -#endif - - -// [span.comparison], span comparison operators -template -constexpr bool operator==(span l, - span r) -{ - return std::equal(l.begin(), l.end(), r.begin(), r.end()); -} - -template -constexpr bool operator!=(span l, - span r) -{ - return !(l == r); -} - -template -constexpr bool operator<(span l, - span r) -{ - return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end()); -} - -template -constexpr bool operator<=(span l, - span r) -{ - return !(l > r); -} - -template -constexpr bool operator>(span l, - span r) -{ - return r < l; -} - -template -constexpr bool operator>=(span l, - span r) -{ - return !(l < r); -} - -namespace details -{ - // if we only supported compilers with good constexpr support then - // this pair of classes could collapse down to a constexpr function - - // we should use a narrow_cast<> to go to std::size_t, but older compilers may not see it as - // constexpr - // and so will fail compilation of the template - template - struct calculate_byte_size - : std::integral_constant(sizeof(ElementType) * - static_cast(Extent))> - { - }; - - template - struct calculate_byte_size - : std::integral_constant - { - }; -} - -// [span.objectrep], views of object representation -template -span::value> -as_bytes(span s) noexcept -{ - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -template ::value>> -span::value> -as_writeable_bytes(span s) noexcept -{ - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -// -// make_span() - Utility functions for creating spans -// -template -constexpr span make_span(ElementType* ptr, typename span::index_type count) -{ - return span(ptr, count); -} - -template -constexpr span make_span(ElementType* firstElem, ElementType* lastElem) -{ - return span(firstElem, lastElem); -} - -template -constexpr span make_span(ElementType (&arr)[N]) noexcept -{ - return span(arr); -} - -template -constexpr span make_span(Container& cont) -{ - return span(cont); -} - -template -constexpr span make_span(const Container& cont) -{ - return span(cont); -} - -template -constexpr span make_span(Ptr& cont, std::ptrdiff_t count) -{ - return span(cont, count); -} - -template -constexpr span make_span(Ptr& cont) -{ - return span(cont); -} - -// Specialization of gsl::at for span -template -constexpr ElementType& at(span s, index i) -{ - // No bounds checking here because it is done in span::operator[] called below - return s[i]; -} - -} // namespace gsl - -#ifdef _MSC_VER -#if _MSC_VER < 1910 -#undef constexpr -#pragma pop_macro("constexpr") - -#endif // _MSC_VER < 1910 - -#pragma warning(pop) -#endif // _MSC_VER - -#if __GNUC__ > 6 -#pragma GCC diagnostic pop -#endif // __GNUC__ > 6 - -#endif // GSL_SPAN_H diff --git a/inst/include/gsl/string_span b/inst/include/gsl/string_span deleted file mode 100644 index c08f246..0000000 --- a/inst/include/gsl/string_span +++ /dev/null @@ -1,730 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GSL_STRING_SPAN_H -#define GSL_STRING_SPAN_H - -#include // for Ensures, Expects -#include // for narrow_cast -#include // for operator!=, operator==, dynamic_extent - -#include // for equal, lexicographical_compare -#include // for array -#include // for ptrdiff_t, size_t, nullptr_t -#include // for PTRDIFF_MAX -#include -#include // for basic_string, allocator, char_traits -#include // for declval, is_convertible, enable_if_t, add_... - -#ifdef _MSC_VER -#pragma warning(push) - -// blanket turn off warnings from CppCoreCheck for now -// so people aren't annoyed by them when running the tool. -// more targeted suppressions will be added in a future update to the GSL -#pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495) - -#if _MSC_VER < 1910 -#pragma push_macro("constexpr") -#define constexpr /*constexpr*/ - -#endif // _MSC_VER < 1910 -#endif // _MSC_VER - -// In order to test the library, we need it to throw exceptions that we can catch -#ifdef GSL_THROW_ON_CONTRACT_VIOLATION -#define GSL_NOEXCEPT /*noexcept*/ -#else -#define GSL_NOEXCEPT noexcept -#endif // GSL_THROW_ON_CONTRACT_VIOLATION - -namespace gsl -{ -// -// czstring and wzstring -// -// These are "tag" typedefs for C-style strings (i.e. null-terminated character arrays) -// that allow static analysis to help find bugs. -// -// There are no additional features/semantics that we can find a way to add inside the -// type system for these types that will not either incur significant runtime costs or -// (sometimes needlessly) break existing programs when introduced. -// - -template -using basic_zstring = CharT*; - -template -using czstring = basic_zstring; - -template -using cwzstring = basic_zstring; - -template -using cu16zstring = basic_zstring; - -template -using cu32zstring = basic_zstring; - -template -using zstring = basic_zstring; - -template -using wzstring = basic_zstring; - -template -using u16zstring = basic_zstring; - -template -using u32zstring = basic_zstring; - -namespace details -{ - template - std::ptrdiff_t string_length(const CharT* str, std::ptrdiff_t n) - { - if (str == nullptr || n <= 0) return 0; - - const span str_span{str, n}; - - std::ptrdiff_t len = 0; - while (len < n && str_span[len]) len++; - - return len; - } -} - -// -// ensure_sentinel() -// -// Provides a way to obtain an span from a contiguous sequence -// that ends with a (non-inclusive) sentinel value. -// -// Will fail-fast if sentinel cannot be found before max elements are examined. -// -template -span ensure_sentinel(T* seq, std::ptrdiff_t max = PTRDIFF_MAX) -{ - auto cur = seq; - while ((cur - seq) < max && *cur != Sentinel) ++cur; - Ensures(*cur == Sentinel); - return {seq, cur - seq}; -} - -// -// ensure_z - creates a span for a zero terminated strings. -// Will fail fast if a null-terminator cannot be found before -// the limit of size_type. -// -template -span ensure_z(CharT* const& sz, std::ptrdiff_t max = PTRDIFF_MAX) -{ - return ensure_sentinel(sz, max); -} - -template -span ensure_z(CharT (&sz)[N]) -{ - return ensure_z(&sz[0], static_cast(N)); -} - -template -span::type, dynamic_extent> -ensure_z(Cont& cont) -{ - return ensure_z(cont.data(), static_cast(cont.size())); -} - -template -class basic_string_span; - -namespace details -{ - template - struct is_basic_string_span_oracle : std::false_type - { - }; - - template - struct is_basic_string_span_oracle> : std::true_type - { - }; - - template - struct is_basic_string_span : is_basic_string_span_oracle> - { - }; -} - -// -// string_span and relatives -// -template -class basic_string_span -{ -public: - using element_type = CharT; - using pointer = std::add_pointer_t; - using reference = std::add_lvalue_reference_t; - using const_reference = std::add_lvalue_reference_t>; - using impl_type = span; - - using index_type = typename impl_type::index_type; - using iterator = typename impl_type::iterator; - using const_iterator = typename impl_type::const_iterator; - using reverse_iterator = typename impl_type::reverse_iterator; - using const_reverse_iterator = typename impl_type::const_reverse_iterator; - - // default (empty) - constexpr basic_string_span() GSL_NOEXCEPT = default; - - // copy - constexpr basic_string_span(const basic_string_span& other) GSL_NOEXCEPT = default; - - // assign - constexpr basic_string_span& operator=(const basic_string_span& other) GSL_NOEXCEPT = default; - - constexpr basic_string_span(pointer ptr, index_type length) : span_(ptr, length) {} - constexpr basic_string_span(pointer firstElem, pointer lastElem) : span_(firstElem, lastElem) {} - - // From static arrays - if 0-terminated, remove 0 from the view - // All other containers allow 0s within the length, so we do not remove them - template - constexpr basic_string_span(element_type (&arr)[N]) : span_(remove_z(arr)) - { - } - - template > - constexpr basic_string_span(std::array& arr) GSL_NOEXCEPT : span_(arr) - { - } - - template > - constexpr basic_string_span(const std::array& arr) GSL_NOEXCEPT - : span_(arr) - { - } - - // Container signature should work for basic_string after C++17 version exists - template - constexpr basic_string_span(std::basic_string& str) - : span_(&str[0], narrow_cast(str.length())) - { - } - - template - constexpr basic_string_span(const std::basic_string& str) - : span_(&str[0], str.length()) - { - } - - // from containers. Containers must have a pointer type and data() function signatures - template ::value && - std::is_convertible::value && - std::is_convertible().data())>::value>> - constexpr basic_string_span(Container& cont) : span_(cont) - { - } - - template ::value && - std::is_convertible::value && - std::is_convertible().data())>::value>> - constexpr basic_string_span(const Container& cont) : span_(cont) - { - } - - // from string_span - template < - class OtherValueType, std::ptrdiff_t OtherExtent, - class = std::enable_if_t::impl_type, impl_type>::value>> - constexpr basic_string_span(basic_string_span other) - : span_(other.data(), other.length()) - { - } - - template - constexpr basic_string_span first() const - { - return {span_.template first()}; - } - - constexpr basic_string_span first(index_type count) const - { - return {span_.first(count)}; - } - - template - constexpr basic_string_span last() const - { - return {span_.template last()}; - } - - constexpr basic_string_span last(index_type count) const - { - return {span_.last(count)}; - } - - template - constexpr basic_string_span subspan() const - { - return {span_.template subspan()}; - } - - constexpr basic_string_span - subspan(index_type offset, index_type count = dynamic_extent) const - { - return {span_.subspan(offset, count)}; - } - - constexpr reference operator[](index_type idx) const { return span_[idx]; } - constexpr reference operator()(index_type idx) const { return span_[idx]; } - - constexpr pointer data() const { return span_.data(); } - - constexpr index_type length() const GSL_NOEXCEPT { return span_.size(); } - constexpr index_type size() const GSL_NOEXCEPT { return span_.size(); } - constexpr index_type size_bytes() const GSL_NOEXCEPT { return span_.size_bytes(); } - constexpr index_type length_bytes() const GSL_NOEXCEPT { return span_.length_bytes(); } - constexpr bool empty() const GSL_NOEXCEPT { return size() == 0; } - - constexpr iterator begin() const GSL_NOEXCEPT { return span_.begin(); } - constexpr iterator end() const GSL_NOEXCEPT { return span_.end(); } - - constexpr const_iterator cbegin() const GSL_NOEXCEPT { return span_.cbegin(); } - constexpr const_iterator cend() const GSL_NOEXCEPT { return span_.cend(); } - - constexpr reverse_iterator rbegin() const GSL_NOEXCEPT { return span_.rbegin(); } - constexpr reverse_iterator rend() const GSL_NOEXCEPT { return span_.rend(); } - - constexpr const_reverse_iterator crbegin() const GSL_NOEXCEPT { return span_.crbegin(); } - constexpr const_reverse_iterator crend() const GSL_NOEXCEPT { return span_.crend(); } - -private: - static impl_type remove_z(pointer const& sz, std::ptrdiff_t max) - { - return {sz, details::string_length(sz, max)}; - } - - template - static impl_type remove_z(element_type (&sz)[N]) - { - return remove_z(&sz[0], narrow_cast(N)); - } - - impl_type span_; -}; - -template -using string_span = basic_string_span; - -template -using cstring_span = basic_string_span; - -template -using wstring_span = basic_string_span; - -template -using cwstring_span = basic_string_span; - -template -using u16string_span = basic_string_span; - -template -using cu16string_span = basic_string_span; - -template -using u32string_span = basic_string_span; - -template -using cu32string_span = basic_string_span; - -// -// to_string() allow (explicit) conversions from string_span to string -// - -template -std::basic_string::type> -to_string(basic_string_span view) -{ - return {view.data(), static_cast(view.length())}; -} - -template , - typename Allocator = std::allocator, typename gCharT, std::ptrdiff_t Extent> -std::basic_string to_basic_string(basic_string_span view) -{ - return {view.data(), static_cast(view.length())}; -} - -template -basic_string_span::value> -as_bytes(basic_string_span s) noexcept -{ - return { reinterpret_cast(s.data()), s.size_bytes() }; -} - -template ::value>> -basic_string_span::value> -as_writeable_bytes(basic_string_span s) noexcept -{ - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -// zero-terminated string span, used to convert -// zero-terminated spans to legacy strings -template -class basic_zstring_span -{ -public: - using value_type = CharT; - using const_value_type = std::add_const_t; - - using pointer = std::add_pointer_t; - using const_pointer = std::add_pointer_t; - - using zstring_type = basic_zstring; - using const_zstring_type = basic_zstring; - - using impl_type = span; - using string_span_type = basic_string_span; - - constexpr basic_zstring_span(impl_type s) GSL_NOEXCEPT : span_(s) - { - // expects a zero-terminated span - Expects(s[s.size() - 1] == '\0'); - } - - // copy - constexpr basic_zstring_span(const basic_zstring_span& other) = default; - - // move - constexpr basic_zstring_span(basic_zstring_span&& other) = default; - - // assign - constexpr basic_zstring_span& operator=(const basic_zstring_span& other) = default; - - // move assign - constexpr basic_zstring_span& operator=(basic_zstring_span&& other) = default; - - constexpr bool empty() const GSL_NOEXCEPT { return span_.size() == 0; } - - constexpr string_span_type as_string_span() const GSL_NOEXCEPT - { - auto sz = span_.size(); - return { span_.data(), sz > 1 ? sz - 1 : 0 }; - } - constexpr string_span_type ensure_z() const GSL_NOEXCEPT { return gsl::ensure_z(span_); } - - constexpr const_zstring_type assume_z() const GSL_NOEXCEPT { return span_.data(); } - -private: - impl_type span_; -}; - -template -using zstring_span = basic_zstring_span; - -template -using wzstring_span = basic_zstring_span; - -template -using u16zstring_span = basic_zstring_span; - -template -using u32zstring_span = basic_zstring_span; - -template -using czstring_span = basic_zstring_span; - -template -using cwzstring_span = basic_zstring_span; - -template -using cu16zstring_span = basic_zstring_span; - -template -using cu32zstring_span = basic_zstring_span; - -// operator == -template ::value || - std::is_convertible>>::value>> -bool operator==(const gsl::basic_string_span& one, const T& other) GSL_NOEXCEPT -{ - const gsl::basic_string_span> tmp(other); - return std::equal(one.begin(), one.end(), tmp.begin(), tmp.end()); -} - -template ::value && - std::is_convertible>>::value>> -bool operator==(const T& one, const gsl::basic_string_span& other) GSL_NOEXCEPT -{ - gsl::basic_string_span> tmp(one); - return std::equal(tmp.begin(), tmp.end(), other.begin(), other.end()); -} - -// operator != -template , Extent>>::value>> -bool operator!=(gsl::basic_string_span one, const T& other) GSL_NOEXCEPT -{ - return !(one == other); -} - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename = std::enable_if_t< - std::is_convertible, Extent>>::value && - !gsl::details::is_basic_string_span::value>> -bool operator!=(const T& one, gsl::basic_string_span other) GSL_NOEXCEPT -{ - return !(one == other); -} - -// operator< -template , Extent>>::value>> -bool operator<(gsl::basic_string_span one, const T& other) GSL_NOEXCEPT -{ - const gsl::basic_string_span, Extent> tmp(other); - return std::lexicographical_compare(one.begin(), one.end(), tmp.begin(), tmp.end()); -} - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename = std::enable_if_t< - std::is_convertible, Extent>>::value && - !gsl::details::is_basic_string_span::value>> -bool operator<(const T& one, gsl::basic_string_span other) GSL_NOEXCEPT -{ - gsl::basic_string_span, Extent> tmp(one); - return std::lexicographical_compare(tmp.begin(), tmp.end(), other.begin(), other.end()); -} - -#ifndef _MSC_VER - -// VS treats temp and const containers as convertible to basic_string_span, -// so the cases below are already covered by the previous operators - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename DataType = typename T::value_type, - typename = std::enable_if_t< - !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && - std::is_convertible::value && - std::is_same().size(), *std::declval().data())>, - DataType>::value>> -bool operator<(gsl::basic_string_span one, const T& other) GSL_NOEXCEPT -{ - gsl::basic_string_span, Extent> tmp(other); - return std::lexicographical_compare(one.begin(), one.end(), tmp.begin(), tmp.end()); -} - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename DataType = typename T::value_type, - typename = std::enable_if_t< - !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && - std::is_convertible::value && - std::is_same().size(), *std::declval().data())>, - DataType>::value>> -bool operator<(const T& one, gsl::basic_string_span other) GSL_NOEXCEPT -{ - gsl::basic_string_span, Extent> tmp(one); - return std::lexicographical_compare(tmp.begin(), tmp.end(), other.begin(), other.end()); -} -#endif - -// operator <= -template , Extent>>::value>> -bool operator<=(gsl::basic_string_span one, const T& other) GSL_NOEXCEPT -{ - return !(other < one); -} - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename = std::enable_if_t< - std::is_convertible, Extent>>::value && - !gsl::details::is_basic_string_span::value>> -bool operator<=(const T& one, gsl::basic_string_span other) GSL_NOEXCEPT -{ - return !(other < one); -} - -#ifndef _MSC_VER - -// VS treats temp and const containers as convertible to basic_string_span, -// so the cases below are already covered by the previous operators - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename DataType = typename T::value_type, - typename = std::enable_if_t< - !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && - std::is_convertible::value && - std::is_same().size(), *std::declval().data())>, - DataType>::value>> -bool operator<=(gsl::basic_string_span one, const T& other) GSL_NOEXCEPT -{ - return !(other < one); -} - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename DataType = typename T::value_type, - typename = std::enable_if_t< - !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && - std::is_convertible::value && - std::is_same().size(), *std::declval().data())>, - DataType>::value>> -bool operator<=(const T& one, gsl::basic_string_span other) GSL_NOEXCEPT -{ - return !(other < one); -} -#endif - -// operator> -template , Extent>>::value>> -bool operator>(gsl::basic_string_span one, const T& other) GSL_NOEXCEPT -{ - return other < one; -} - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename = std::enable_if_t< - std::is_convertible, Extent>>::value && - !gsl::details::is_basic_string_span::value>> -bool operator>(const T& one, gsl::basic_string_span other) GSL_NOEXCEPT -{ - return other < one; -} - -#ifndef _MSC_VER - -// VS treats temp and const containers as convertible to basic_string_span, -// so the cases below are already covered by the previous operators - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename DataType = typename T::value_type, - typename = std::enable_if_t< - !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && - std::is_convertible::value && - std::is_same().size(), *std::declval().data())>, - DataType>::value>> -bool operator>(gsl::basic_string_span one, const T& other) GSL_NOEXCEPT -{ - return other < one; -} - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename DataType = typename T::value_type, - typename = std::enable_if_t< - !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && - std::is_convertible::value && - std::is_same().size(), *std::declval().data())>, - DataType>::value>> -bool operator>(const T& one, gsl::basic_string_span other) GSL_NOEXCEPT -{ - return other < one; -} -#endif - -// operator >= -template , Extent>>::value>> -bool operator>=(gsl::basic_string_span one, const T& other) GSL_NOEXCEPT -{ - return !(one < other); -} - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename = std::enable_if_t< - std::is_convertible, Extent>>::value && - !gsl::details::is_basic_string_span::value>> -bool operator>=(const T& one, gsl::basic_string_span other) GSL_NOEXCEPT -{ - return !(one < other); -} - -#ifndef _MSC_VER - -// VS treats temp and const containers as convertible to basic_string_span, -// so the cases below are already covered by the previous operators - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename DataType = typename T::value_type, - typename = std::enable_if_t< - !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && - std::is_convertible::value && - std::is_same().size(), *std::declval().data())>, - DataType>::value>> -bool operator>=(gsl::basic_string_span one, const T& other) GSL_NOEXCEPT -{ - return !(one < other); -} - -template < - typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T, - typename DataType = typename T::value_type, - typename = std::enable_if_t< - !gsl::details::is_span::value && !gsl::details::is_basic_string_span::value && - std::is_convertible::value && - std::is_same().size(), *std::declval().data())>, - DataType>::value>> -bool operator>=(const T& one, gsl::basic_string_span other) GSL_NOEXCEPT -{ - return !(one < other); -} -#endif -} // namespace gsl - -#undef GSL_NOEXCEPT - -#ifdef _MSC_VER -#pragma warning(pop) - -#if _MSC_VER < 1910 -#undef constexpr -#pragma pop_macro("constexpr") - -#endif // _MSC_VER < 1910 -#endif // _MSC_VER - -#endif // GSL_STRING_SPAN_H diff --git a/inst/include/highfive/H5DataSet.hpp b/inst/include/highfive/H5DataSet.hpp index 33bbc20..2accea1 100644 --- a/inst/include/highfive/H5DataSet.hpp +++ b/inst/include/highfive/H5DataSet.hpp @@ -35,25 +35,43 @@ class DataSet : public Object, void extend(const std::vector &new_dims); size_t getStorageSize() const; + + /// + /// /brief get_num_chunks + /// /return return the number of chunks in each dimension + std::vector get_num_chunks() const; + + + /// + /// /brief get_chunk_offset + /// /return return the chunk offset at the specified chunk index + std::vector get_chunk_offset(const std::vector &chunk_idx) const; + /// /// \brief getDataType /// \return return the datatype associated with this dataset /// - DataType getDataType() const; + DataType getDataType() const; - //std::vector getDataDimensions() const; - /// - /// \brief getSpace - /// \return return the dataspace associated with this dataset - /// - DataSpace getSpace() const; - /// - /// \brief getFilter - /// \return return the filter(compression) associated with this dataset - /// - Filter getFilter() const; + std::optional read_raw_chunk(std::vector &data_buff,const std::vector &offsets)const; + + + void write_raw_chunk(std::vector &data_buff, const std::vector &offsets,std::optional buff_size) const; + //std::vector getDataDimensions() const; + + /// + /// \brief getSpace + /// \return return the dataspace associated with this dataset + /// + DataSpace getSpace() const; + + /// + /// \brief getFilter + /// \return return the filter(compression) associated with this dataset + /// + Filter getFilter() const; /// /// \brief getMemSpace diff --git a/inst/include/highfive/H5DataType.hpp b/inst/include/highfive/H5DataType.hpp index 6ac58f3..5cf3399 100644 --- a/inst/include/highfive/H5DataType.hpp +++ b/inst/include/highfive/H5DataType.hpp @@ -12,26 +12,33 @@ #include namespace HighFive { -struct TypeMapper; + struct TypeMapper; -/// -/// \brief HDF5 Data Type -/// -class DataType : public Object { + /// + /// \brief HDF5 Data Type + /// + class DataType : public Object { public: DataType(); bool operator == (const DataType& other) const; bool operator != (const DataType& other) const; + H5T_class_t get_class() const{ + return H5Tget_class(_hid); + } + bool same_class(const DataType& other) const{ + return this->get_class()==other.get_class(); + } + size_t n_elem() const; -protected: + protected: friend class Attribute; friend class File; friend class DataSet; -}; + }; /// /// \brief create an HDF5 DataType from a C++ type diff --git a/inst/include/highfive/H5File.hpp b/inst/include/highfive/H5File.hpp index a4c1a2f..5a486d8 100644 --- a/inst/include/highfive/H5File.hpp +++ b/inst/include/highfive/H5File.hpp @@ -52,13 +52,13 @@ class File : public Object, /// Open or create a new HDF5 file explicit File(const std::string& filename, int openFlags = ReadOnly, const FileDriver& driver = DefaultFileDriver()); - bool start_swmr(); + // bool start_swmr(); /// /// \brief Return the name of the file /// const std::string& getName() const; size_t getObjCount(unsigned int types) const; - static boost::optional openFile(const std::string& filename, int openFlags = ReadOnly, + static std::optional openFile(const std::string& filename, int openFlags = ReadOnly, const FileDriver& driver = DefaultFileDriver()); /// /// \brief flush diff --git a/inst/include/highfive/H5Filter.hpp b/inst/include/highfive/H5Filter.hpp index 13ba0ce..025c70d 100644 --- a/inst/include/highfive/H5Filter.hpp +++ b/inst/include/highfive/H5Filter.hpp @@ -10,65 +10,349 @@ #include "H5DataSpace.hpp" #include #include - +#include +#include #include +#ifdef USE_BLOSC +#include "blosc_filter.h" +#endif +#ifdef USE_LZF +#include "lzf/lzf_filter.h" +#endif +#include "zstd/zstd_h5plugin.h" +#include "zstd/zstd.h" +#include "zlib.h" -namespace HighFive { +class NoCompressor{ +public: + NoCompressor(const std::vector &cd){} + void decompress(void* uncompressed,size_t uc_size,const void* compressed,std::optional cb_size){ + std::memcpy(uncompressed,compressed,cb_size.value_or(uc_size)); + } - // class VFilter :public Object{ + std::optional compress(void* compressed,size_t cb_size,const void* uncompressed,size_t uc_size){ +#ifdef DEBUG + if(uc_size>cb_size){ + Rcpp::stop("compressed buffer is smaller than uncompressed buffer in NoCompressor"); + } +#endif + std::memcpy(compressed,uncompressed,uc_size); + return uc_size; + } +}; - // }; -/// + + +class GzipCompressor{ +public: + const int aggression; + GzipCompressor(const std::vector &cd_):aggression(static_cast(cd_[0])){} + void decompress(void* uncompressed,size_t uc_size,const void* compressed,std::optional cb_size){ + if(cb_size){ + size_t tcb_size=uc_size; + + auto ret = uncompress(reinterpret_cast(uncompressed), + &tcb_size, + reinterpret_cast(compressed), + cb_size.value()); + // ret = uncompress((Bytef *)read_dst_buf, (uLongf *)&buf_size, pt_readbuf, (uLong)read_chunk_nbytes); + + if(Z_BUF_ERROR == ret) { + Rcpp::stop("Error decompressing data"); + } + } + else{ + std::memcpy(uncompressed,compressed,uc_size); + } + } + + + std::optional compress(void* compressed,size_t cb_size,const void* uncompressed,size_t uc_size){ + size_t o_cb_size=cb_size; + auto ret = compress2(reinterpret_cast(compressed), &cb_size,reinterpret_cast(uncompressed),uc_size, aggression); + if(Z_BUF_ERROR == ret) { + Rcpp::stop("zbuff overflow"); + } else if(Z_MEM_ERROR == ret) { + Rcpp::stop("deflate memory error"); + } else if(Z_OK != ret) { + Rcpp::stop("other deflate error"); + } + if(cb_size &cd_){ +#ifndef USE_LZF + Rcpp::stop("please recompile EigenH5 with -DUSE_LZF (and the lzf library)"); +#endif + + } + void memcpy(void* output,size_t osize,const void* input,size_t isize){ + std::memcpy(output,input,osize); + } + void decompress(void* uncompressed,size_t uc_size,const void* compressed,std::optional cb_size){ +#ifndef USE_LZF + Rcpp::stop("please recompile EigenH5 with -DUSE_LZF (and the lzf library)"); +#else + + if(cb_size){ + auto ret = lzf_decompress(compressed,cb_size.value(),uncompressed,uc_size); + if(!ret){ + if(errno == E2BIG){ + Rcpp::stop("lzf too small"); + } else if(errno == EINVAL) { + + Rcpp::stop("Invalid data for LZF decompression"); + + } else { + Rcpp::stop("Unknown LZF decompression error"); + } + + + if(Z_BUF_ERROR == ret) { + Rcpp::stop("Error decompressing data"); + } + } + }else{ + std::memcpy(uncompressed,compressed,uc_size); + } +#endif + } + std::optional compress(void* compressed,size_t cb_size,const void* uncompressed,const size_t uc_size) noexcept{ +#ifndef USE_LZF + Rcpp::stop("please recompile EigenH5 with -DUSE_LZF (and the lzf library)"); +#else + auto ret = lzf_compress(uncompressed,uc_size,compressed,cb_size); + if(ret>0){ + return(ret); + }else{ + std::memcpy(compressed,uncompressed,uc_size); + return std::nullopt; + } +#endif + } + + +}; + + + +class BloscCompressor{ +#ifdef USE_BLOSC + int clevel; + int doshuffle; + int compcode; + int code; + int typesize; + int outbuf_size; +#endif + +public: + BloscCompressor(const std::vector cd_){ +#ifndef USE_BLOSC + Rcpp::stop("please recompile EigenH5 with -DUSE_BLOSC (and the blosc library)"); +#else + + char tstr [] = "blosclz"; + const char* compname = tstr; /* The compressor by default */ + auto cds =cd_.size(); + if(cds>4){ + typesize=static_cast(cd_[2]); + outbuf_size=static_cast(cd_[3]); + }else{ + Rcpp::stop("Blosc Compressor needs the values from cd_"); + } + if(cds>=5){ + clevel=static_cast(cd_[4]); + }else{ + clevel=5; + } + if(cds>=6){ + doshuffle=static_cast(cd_[5]); + }else{ + doshuffle=1; + } + if(cds>=7){ + compcode=static_cast(cd_[6]); + auto complist = blosc_list_compressors(); + code = blosc_compcode_to_compname(compcode, &compname); + if (code == -1) { + Rcpp::Rcerr<<"this Blosc library does not have support for the "< cb_size){ +#ifdef USE_BLOSC + if(cb_size){ + size_t cbytes, blocksize,outbuf_size; + size_t osize=uc_size; + blosc_cbuffer_sizes(compressed, &outbuf_size, &cbytes, &blocksize); + if(outbuf_size>osize){ + Rcpp::stop("output buffer size larger than total size!"); + } + auto status = blosc_decompress(compressed, uncompressed, uc_size); + if (status <= 0) { /* decompression failed */ + Rcpp::stop("Blosc decompression error"); + } + }else{ + std::memcpy(uncompressed,compressed,uc_size); + } +#endif + } + + std::optional compress(void* compressed,size_t cb_size,const void* uncompressed,size_t uc_size){ +#ifdef USE_BLOSC + size_t cbytes, blocksize,outbuf_size; + auto status = blosc_compress(clevel,doshuffle,typesize,uc_size,uncompressed,compressed,cb_size); + if (status <= 0) { /* decompression failed */ + std::memcpy(compressed,uncompressed,uc_size); + return std::nullopt; + } + return(status); + #else + Rcpp::stop("Rebuild EigenH5 using BLOSC"); + return(std::nullopt); +#endif + } +}; + + + + +class ZstdCompressor{ +public: + std::unique_ptr ctxt_d; + std::unique_ptr ctxt_c; + int aggression; + ZstdCompressor(const std::vector cd_):ctxt_d(ZSTD_createDCtx(),&ZSTD_freeDCtx), + ctxt_c(ZSTD_createCCtx(),&ZSTD_freeCCtx){ + if(cd_.size()>0){ + aggression=static_cast(cd_[0]); + }else{ + aggression=22; + } + } + // std::optional compress(void* compressed,size_t cb_size,const void* uncompressed,size_t uc_size){ + void decompress(void* uncompressed,size_t uc_size,const void* compressed,std::optional cb_size){ + if(cb_size){ + auto rc = ZSTD_decompressDCtx(ctxt_d.get(),uncompressed, uc_size, compressed,cb_size.value()); + if(ZSTD_isError(rc)){ + Rcpp::Rcerr< compress(void* compressed,size_t cb_size,const void* uncompressed,size_t uc_size){ + + auto rc = ZSTD_compressCCtx(ctxt_c.get(),compressed, cb_size,uncompressed,uc_size,aggression); + if(ZSTD_isError(rc)){ + Rcpp::Rcerr<<"There was an error with compression!"< &chunk_dims, const hid_t filter_id, std::vector cd_values); - Filter(); - static std::vector guess_chunk(const std::vector data_shape); - static Filter From(const DataSpace &dataspace,const hid_t filter_id,std::vector cd_values={}); - hid_t getId() const; - std::vector get_chunksizes()const; - std::pair > get_filter_info() const; - protected: - std::vector chunksizes; - hid_t _hid; - friend class ::HighFive::DataSet; - }; + class Filter: public Object { + + public: + static const hid_t gzip;// = 1; + static const hid_t blosc;// = 32001; + static const hid_t lzf4;// = 32000; + static const hid_t zstd;// = 32015; + static const hid_t no_filter;// = 0; + static const size_t CHUNK_BASE = 16*1024; + static const size_t CHUNK_MIN = 8*1024; + static const size_t CHUNK_MAX = 1024*1024; + Filter(const std::vector &chunk_dims, const hid_t filter_id, std::vector cd_values); + using compressors = std::variant; + Filter(); + static std::vector guess_chunk(const std::vector data_shape); + static Filter From(const DataSpace &dataspace,const hid_t filter_id,std::vector cd_values={}); + hid_t getId() const; + std::vector get_chunksizes()const; + compressors getDecompressor() const; + std::pair > get_filter_info() const; + protected: + std::vector chunksizes; + // hid_t _hid; + friend class ::HighFive::DataSet; + }; -} // HighFive +} // HighFive -namespace HighFive { +namespace HighFive { -const hid_t filter_gzip = 1; -const hid_t filter_blosc = 32001; -const hid_t filter_lzf4 = 32000; -const hid_t filter_zstd = 32015; -const hid_t filter_no_filter = 0; + const hid_t filter_gzip = 1; + const hid_t filter_blosc = 32001; + const hid_t filter_lzf4 = 32000; + const hid_t filter_zstd = 32015; + const hid_t filter_no_filter = 0; inline Filter::Filter() { _hid = H5Pcreate(H5P_DATASET_CREATE); @@ -140,9 +424,7 @@ const hid_t filter_no_filter = 0; } auto chunk_size=data_shape; size_t prop_chunk_size = std::accumulate(chunk_size.begin(), chunk_size.end(), 1, std::multiplies()); - size_t iti=0; while(prop_chunk_size>=CHUNK_MAX){ - // auto it=data_shape[(iti++ % auto it=chunk_size.begin(); *it/=2; prop_chunk_size = std::accumulate(chunk_size.begin(), chunk_size.end(), 1, std::multiplies()); @@ -173,6 +455,9 @@ const hid_t filter_no_filter = 0; nname, name.data(), &tflg); + if(filt_ret<0){ + HDF5ErrMapper::ToException("Unable to get filter"); + } std::string nameret(name.data()); std::vector ret(ncd); std::copy(cd.begin(),cd.begin()+ncd,ret.begin()); @@ -180,9 +465,54 @@ const hid_t filter_no_filter = 0; }else{ return(std::make_pair("no_filter",std::vector())); } + } - - + inline Filter::compressors Filter::getDecompressor() const{ + std::vector cd(10); + std::array flgs; + unsigned int tflg; + std::vector name(30); + size_t ncd=cd.size(); + size_t nname = name.size(); + //We want to get the last filter + int num_filt=H5Pget_nfilters(_hid); + if(num_filt>0){ + auto filt_ret=H5Pget_filter(_hid, + num_filt-1, + flgs.data(), + &ncd, + cd.data(), + nname, + name.data(), + &tflg); + if(filt_ret<0){ + HDF5ErrMapper::ToException("Unable to get filter"); + } + switch(filt_ret){ + case H5Z_FILTER_DEFLATE:{ + // GzipCompressor gzd(cd); + return(GzipCompressor(cd)); + } + case 32001:{ + // BloscCompressor blodo(cd); + return(BloscCompressor(cd)); + } + case 32000:{ + // LzfCompressor lzd(cd); + return(LzfCompressor(cd)); + } + case 32015:{ + // ZstdCompressor zstdd(cd); + return(ZstdCompressor(cd)); + } + default: { + Rcpp::Rcerr<<"Invalid filter:"<< filt_ret< Filter::get_chunksizes()const{ diff --git a/inst/include/highfive/bits/H5Annotate_traits.hpp b/inst/include/highfive/bits/H5Annotate_traits.hpp index 6f1f65e..69a5aab 100644 --- a/inst/include/highfive/bits/H5Annotate_traits.hpp +++ b/inst/include/highfive/bits/H5Annotate_traits.hpp @@ -49,7 +49,7 @@ class AnnotateTraits { /// \return the attribute object /// Attribute getAttribute(const std::string& attribute_name) const; - boost::optional openAttribute(const std::string& attribute_name) const; + std::optional openAttribute(const std::string& attribute_name) const; /// /// \brief return the number of attributes of the node / group diff --git a/inst/include/highfive/bits/H5Annotate_traits_misc.hpp b/inst/include/highfive/bits/H5Annotate_traits_misc.hpp index 9d8d554..cfac6e9 100644 --- a/inst/include/highfive/bits/H5Annotate_traits_misc.hpp +++ b/inst/include/highfive/bits/H5Annotate_traits_misc.hpp @@ -49,10 +49,10 @@ AnnotateTraits::createAttribute(const std::string& attribute_name, template -inline boost::optional AnnotateTraits::openAttribute( +inline std::optional AnnotateTraits::openAttribute( const std::string& attribute_name) const { if(!this->hasAttribute(attribute_name)){ - return(boost::none); + return(std::nullopt); }else{ return(this->getAttribute(attribute_name)); } @@ -89,14 +89,14 @@ inline std::vector AnnotateTraits::listAttributeNames() const { std::vector names; - details::HighFiveIterateData iterateData(names); + details::HighFiveIterateData iterateData(names); size_t num_objs = getNumberAttributes(); names.reserve(num_objs); if (H5Aiterate2(static_cast(this)->getId(), H5_INDEX_NAME, H5_ITER_INC, NULL, - &details::internal_high_five_iterate, + &details::internal_high_five_iterate, static_cast(&iterateData)) < 0) { HDF5ErrMapper::ToException( std::string("Unable to list attributes in group")); diff --git a/inst/include/highfive/bits/H5Converter_misc.hpp b/inst/include/highfive/bits/H5Converter_misc.hpp index 761c774..ebcd50c 100644 --- a/inst/include/highfive/bits/H5Converter_misc.hpp +++ b/inst/include/highfive/bits/H5Converter_misc.hpp @@ -101,7 +101,7 @@ namespace HighFive { inline data_converter(std::vector &vec, DataSpace &space,const DataType dt) : _space( &space), _dim(0) { - assert(_space->getDimensions().size() > dim); + assert(_space->getDimensions().size() > _dim); (void)vec; } @@ -588,6 +588,10 @@ struct data_converter, void> { DataSpace& _space; }; + + + + // template<> // struct data_converter, void> { // inline data_converter(std::vector &vec, DataSpace &space,const size_t dim=0) diff --git a/inst/include/highfive/bits/H5DataSet_misc.hpp b/inst/include/highfive/bits/H5DataSet_misc.hpp index 0ea7bcd..781b61e 100644 --- a/inst/include/highfive/bits/H5DataSet_misc.hpp +++ b/inst/include/highfive/bits/H5DataSet_misc.hpp @@ -30,17 +30,144 @@ namespace HighFive { -inline DataSet::DataSet() {} + inline DataSet::DataSet() {} -inline size_t DataSet::getStorageSize() const { + inline size_t DataSet::getStorageSize() const { return H5Dget_storage_size(_hid); -} + } -inline DataType DataSet::getDataType() const { + inline DataType DataSet::getDataType() const { DataType res; res._hid = H5Dget_type(_hid); return res; -} + } + + + + + + + inline std::vector DataSet::get_num_chunks() const{ + + + auto dim_size = this->getSpace().getDimensions(); + auto filt = this->getFilter(); + const size_t num_dims_ds = dim_size.size(); + + const size_t num_dims_chunks = filt.chunksizes.size(); + + std::vector retvec(num_dims_chunks); + + + if(num_dims_chunks==0){ + return(retvec); + } + + if (num_dims_chunks != num_dims_ds) { + HDF5ErrMapper::ToException( + "Filter chunksize rank does not match dataset rank"); + } + + std::transform(dim_size.begin(),dim_size.end(),filt.chunksizes.begin(),retvec.begin(),std::divides()); + return(retvec); + + } + + + inline std::vector DataSet::get_chunk_offset(const std::vector &chunk_idx) const{ + auto num_chunk_v=get_num_chunks(); + if(chunk_idx.size()!=num_chunk_v.size()){ + HDF5ErrMapper::ToException( + "Filter chunksize rank does not match chunk_idx.size()"); + } + std::vector retvec(chunk_idx.size()); + + if(retvec.size()==0){ + return(retvec); + } + + if (chunk_idx > num_chunk_v) { + HDF5ErrMapper::ToException( + "Chunk index greater than number of chunks!"); + } + + auto filt = this->getFilter(); + const size_t num_dims_chunks = filt.chunksizes.size(); + + std::transform(chunk_idx.begin(), chunk_idx.end(), filt.chunksizes.begin(), retvec.begin(), + std::multiplies()); + return (retvec); + } + + + inline std::optional DataSet::read_raw_chunk(std::vector &data_buff, const std::vector &offsets) const { + hsize_t chunk_nbytes; + + // T ret_vec(read_chunk_nbytes); + uint32_t read_filter_mask = 0; //filter mask after direct read + std::vector h_offsets(offsets.size()); + std::copy(offsets.begin(),offsets.end(),h_offsets.begin()); + + auto ret =H5Dget_chunk_storage_size(_hid, h_offsets.data(), &chunk_nbytes); + auto buff_size = data_buff.size(); + if(chunk_nbytes>buff_size){ + size_t newsize=chunk_nbytes; + // Rcpp::Rcerr<<"resizing from "<( + "Unable to read direct chunk"); + } + if(read_filter_mask!=0){ + return(std::nullopt); + } + + return chunk_nbytes; + } + + + + inline void DataSet::write_raw_chunk(std::vector &data_buff, const std::vector &offsets,std::optional buff_size) const { + uint32_t filter_mask = 0; //filter mask after direct read + + std::vector h_offsets(offsets.size()); + std::copy(offsets.begin(),offsets.end(),h_offsets.begin()); + if(buff_size){ + if(H5Dwrite_chunk(_hid, H5P_DEFAULT, filter_mask, + h_offsets.data(), buff_size.value(), data_buff.data())<0){ + HDF5ErrMapper::ToException( + "Unable to write direct chunk"); + } + }else{ + filter_mask = 0x00000001; + if(H5Dwrite_chunk(_hid, H5P_DEFAULT, filter_mask, + h_offsets.data(), data_buff.size(), data_buff.data())){ + HDF5ErrMapper::ToException( + "Unable to write direct chunk"); + } + } + } + // template + // inline T DataSet::read_raw_chunk(const std::vector &chunk_idx) const { + + // hsize_t read_chunk_nbytes; + + + // auto offset_vec = get_chunk_offset(chunk_idx); + // auto ret =H5Dget_chunk_storage_size(_hid, offset_vec.data(), &read_chunk_nbytes); + // T ret_vec(read_chunk_nbytes); + // unsigned read_filter_mask = 0; filter mask after direct read + + // if ((H5Dread_chunk(_hid, H5P_DEFAULT, offset_vec.data(), + // &read_filter_mask, (void *)&ret_vec[0])) < 0) { + // HDF5ErrMapper::ToException( + // "Unable to read direct chunk"); + // } + // return (ret_vec); + // } inline bool DataSet::isTransposed() const { int transpose_int = 0; @@ -51,9 +178,15 @@ inline DataType DataSet::getDataType() const { } inline void DataSet::extend(const std::vector &new_dims) { - std::vector real_new_dims(new_dims.size()); - std::copy(new_dims.begin(), new_dims.end(), real_new_dims.begin()); - if ((_hid = H5Dset_extent(_hid,real_new_dims.data())) < 0) { + const size_t numDimensions = getSpace().getDimensions().size(); + if(new_dims.size()!=numDimensions){ + HDF5ErrMapper::ToException( + "Invalid dataspace dimensions, got " + std::to_string(new_dims.size()) + + " expected " + std::to_string(numDimensions)); + } + std::vector real_new_dims(new_dims.begin(),new_dims.end()); + // std::copy(new_dims.begin(), new_dims.end(), real_new_dims.begin()); + if ((H5Dset_extent(_hid,real_new_dims.data())) < 0) { HDF5ErrMapper::ToException( "Unable to extend DataSet"); } diff --git a/inst/include/highfive/bits/H5DataType_misc.hpp b/inst/include/highfive/bits/H5DataType_misc.hpp index 8aaf545..66487f9 100644 --- a/inst/include/highfive/bits/H5DataType_misc.hpp +++ b/inst/include/highfive/bits/H5DataType_misc.hpp @@ -19,6 +19,17 @@ namespace HighFive { inline DataType::DataType(){} + inline size_t DataType::n_elem() const{ + auto sup =H5Tget_class(_hid); + bool is_str = sup==H5T_STRING; + // H5Tclose(sup); + if(is_str){ + + return(H5Tget_size(_hid)); + } + return 1; + } + inline bool DataType::operator==(const DataType& other) const { return (H5Tequal(_hid, other._hid) > 0); } @@ -135,9 +146,9 @@ inline AtomicType::AtomicType() { template <> inline AtomicType::AtomicType(int size) { _hid = H5Tcopy(H5T_C_S1); - size = (size < 0) ? H5T_VARIABLE : size; + size_t rsize = (size < 0) ? H5T_VARIABLE : static_cast(size); - if (H5Tset_size(_hid, size) < 0) { + if (H5Tset_size(_hid, rsize) < 0) { HDF5ErrMapper::ToException( "Unable to define datatype size to variable"); } diff --git a/inst/include/highfive/bits/H5File_misc.hpp b/inst/include/highfive/bits/H5File_misc.hpp index c4969df..e20baa7 100644 --- a/inst/include/highfive/bits/H5File_misc.hpp +++ b/inst/include/highfive/bits/H5File_misc.hpp @@ -40,9 +40,9 @@ inline int convert_open_flag(int openFlags) { // return (stat (name.c_str(), &buffer) == 0); // } - inline bool File::start_swmr(){ - return(H5Fstart_swmr_write(_hid) > 0); - } +// inline bool File::start_swmr(){ +// return(H5Fstart_swmr_write(_hid) > 0); + // } inline size_t File::getObjCount(unsigned int types) const{ return (H5Fget_obj_count( _hid,types )); @@ -96,14 +96,14 @@ inline File::File(const std::string& filename, int openFlags, } } - inline boost::optional File::openFile(const std::string& filename, int openFlags,const FileDriver& driver){ + inline std::optional File::openFile(const std::string& filename, int openFlags,const FileDriver& driver){ try{ HighFive::SilenceHDF5 silence; File file(filename,openFlags,driver); return(file); }catch (HighFive::Exception& err) { // Rcpp::StringVector retvec(1); - return(boost::none); + return(std::nullopt); } } diff --git a/inst/include/highfive/bits/H5Iterables_misc.hpp b/inst/include/highfive/bits/H5Iterables_misc.hpp index 54ddcbf..562a657 100644 --- a/inst/include/highfive/bits/H5Iterables_misc.hpp +++ b/inst/include/highfive/bits/H5Iterables_misc.hpp @@ -37,12 +37,12 @@ inline herr_t convert_to_string(void *elem, hid_t type_id, unsigned ndim, namespace details { // iterator for H5 iterate - + template struct HighFiveIterateData { - inline HighFiveIterateData(std::vector& my_names) + inline HighFiveIterateData(std::vector& my_names) : names(my_names), err(NULL) {} - std::vector& names; + std::vector& names; std::exception* err; inline void throwIfError() { @@ -52,21 +52,21 @@ struct HighFiveIterateData { } }; -template + template inline herr_t internal_high_five_iterate(hid_t id, const char* name, const InfoType* info, void* op_data) { (void)id; (void)info; - HighFiveIterateData* data = static_cast(op_data); + HighFiveIterateData* data = static_cast*>(op_data); try { - H5O_info_t tid; + // H5O_info_t tid; #if defined(H5_USE_110_API) - auto ret = H5Oget_info_by_name2(id,name,&tid,H5O_INFO_ALL,H5P_DEFAULT); + // auto ret = H5Oget_info_by_name2(id,name,&tid,H5O_INFO_ALL,H5P_DEFAULT); #else - auto ret = H5Oget_info_by_name(static_cast(this)->getId(), object_name.c_str(), &tid,H5P_DEFAULT); + // auto ret = H5Oget_info_by_name(static_cast(this)->getId(), object_name.c_str(), &tid,H5P_DEFAULT); #endif - data->names.push_back(Path(std::string(name))); + data->names.push_back(T(std::string(name))); return 0; } catch (...) { data->err = diff --git a/inst/include/highfive/bits/H5Node_traits.hpp b/inst/include/highfive/bits/H5Node_traits.hpp index e6b8c67..af23399 100644 --- a/inst/include/highfive/bits/H5Node_traits.hpp +++ b/inst/include/highfive/bits/H5Node_traits.hpp @@ -13,6 +13,8 @@ #include #include "../H5Filter.hpp" +class Path; + namespace HighFive { @@ -81,7 +83,7 @@ class NodeTraits { DataSet getDataSet(const Path& dataset_name) const; - boost::optional openDataSet(const Path& dataset_name) const; + std::optional openDataSet(const Path& dataset_name) const; @@ -101,7 +103,7 @@ class NodeTraits { - boost::optional openGroup(const Path& group_name) const; + std::optional openGroup(const Path& group_name) const; @@ -131,17 +133,17 @@ class NodeTraits { /// /// \brief return either a group or dataset /// \return variant containing either a group or dataset - boost::variant getObject(const Path & object_name) const; + std::variant getObject(const Path & object_name) const; - boost::optional> openObject(const Path & object_name) const; + std::optional> openObject(const Path & object_name) const; /// /// \brief return all leaf objects - /// \return zero or more objects (represented as boost::variants) - std::vector > getObjects() const; + /// \return zero or more objects (represented as std::variants) + std::vector > getObjects() const; bool _exist(const std::string& node_name) const; @@ -154,7 +156,7 @@ class NodeTraits { bool exist(const Path& node_name) const; private: static Group grpCreate(const hid_t root_id, const char* name); - boost::variant getObj(const hid_t root_id, const char* name) const; + std::variant getObj(const hid_t root_id, const char* name) const; typedef Derivate derivate_type; }; } diff --git a/inst/include/highfive/bits/H5Node_traits_misc.hpp b/inst/include/highfive/bits/H5Node_traits_misc.hpp index 8f079a5..3f9cd98 100644 --- a/inst/include/highfive/bits/H5Node_traits_misc.hpp +++ b/inst/include/highfive/bits/H5Node_traits_misc.hpp @@ -85,11 +85,11 @@ namespace HighFive { } template - inline boost::optional + inline std::optional NodeTraits::openDataSet(const Path & dataset_name) const { if(!this->exist(dataset_name)){ - return(boost::none); + return(std::nullopt); } else { return (this->getDataSet(dataset_name)); } @@ -100,7 +100,7 @@ namespace HighFive { auto gcpl = H5Pcreate (H5P_LINK_CREATE); - auto status = H5Pset_create_intermediate_group (gcpl, 1); + H5Pset_create_intermediate_group (gcpl, 1); Group group; if ((group._hid = H5Gcreate2(static_cast(this)->getId(), group_name.c_str(), gcpl, H5P_DEFAULT, @@ -127,10 +127,10 @@ namespace HighFive { } template - inline boost::optional + inline std::optional NodeTraits::openGroup(const Path &group_name) const { if(!this->exist(group_name)){ - return(boost::none); + return(std::nullopt); } else { return (this->getGroup(group_name)); } @@ -209,31 +209,31 @@ namespace HighFive { template - inline boost::variant NodeTraits::getObject(const Path & object_name) const{ + inline std::variant NodeTraits::getObject(const Path & object_name) const{ if(isGroup(object_name)){ return (getGroup(object_name)); } - if (isDataSet(object_name)) { - return (getDataSet(object_name)); + if (!isDataSet(object_name)) { + HDF5ErrMapper::ToException(std::string("Object is not a Group or DataSet: ") + object_name); } - HDF5ErrMapper::ToException(std::string("Object is not a Group or DataSet: ") + object_name); + return (getDataSet(object_name)); } template - inline boost::optional > NodeTraits::openObject(const Path & object_name) const{ + inline std::optional > NodeTraits::openObject(const Path & object_name) const{ if(this->exist(object_name)){ return(this->getObject(object_name)); }else{ - return(boost::none); + return(std::nullopt); } } template - inline std::vector > NodeTraits::getObjects() const { + inline std::vector > NodeTraits::getObjects() const { auto names = this->listObjectNames(); const int num_objs=names.size(); - std::vector > retvec(num_objs); + std::vector > retvec(num_objs); for (int i = 0; i < num_objs; i++) { retvec[i] = this->getObject(names[i]); } @@ -273,14 +273,14 @@ namespace HighFive { std::vector names; - details::HighFiveIterateData iterateData(names); + details::HighFiveIterateData iterateData(names); size_t num_objs = getNumberObjects(); names.reserve(num_objs); if (H5Literate(static_cast(this)->getId(), H5_INDEX_NAME, H5_ITER_NATIVE, NULL, - &details::internal_high_five_iterate, + &details::internal_high_five_iterate, static_cast(&iterateData)) < 0) { HDF5ErrMapper::ToException( std::string("Unable to list objects in group")); diff --git a/inst/include/highfive/bits/H5Slice_traits.hpp b/inst/include/highfive/bits/H5Slice_traits.hpp index 2094990..a6b95f1 100644 --- a/inst/include/highfive/bits/H5Slice_traits.hpp +++ b/inst/include/highfive/bits/H5Slice_traits.hpp @@ -116,7 +116,6 @@ class SliceTraits { /// dimensional array ) template void write(const T& buffer); - /// /// Write from a raw buffer into this dataset /// diff --git a/inst/include/highfive/bits/H5Slice_traits_misc.hpp b/inst/include/highfive/bits/H5Slice_traits_misc.hpp index 707cdfa..8d8bdd9 100644 --- a/inst/include/highfive/bits/H5Slice_traits_misc.hpp +++ b/inst/include/highfive/bits/H5Slice_traits_misc.hpp @@ -135,11 +135,6 @@ inline ElementSet::ElementSet(const std::vector& element_ids) std::copy(offset[i].begin(), offset[i].end(), offset_local.begin()); std::copy(count[i].begin(), count[i].end(), count_local.begin()); - // for(size_t j=0; j::select(const ElementSet& elements) const { template inline std::vector SliceTraits::getDataDimensions() const { const bool doTranspose = details::get_dataset(static_cast(this)).isTransposed(); - // if(doTranspose){ - // HDF5ErrMapper::ToException( - // "Transposed data has been deprecated"); - // } std::vector dims =static_cast(this)->getMemSpace().getDimensions(); if (doTranspose) { std::reverse(dims.begin(), dims.end()); @@ -343,9 +334,10 @@ inline void SliceTraits::read(T &array) { auto mem_datatype = array_datatype.getId(); auto u_id=mem_datatype; - if(H5Tget_size(dt.getId())>255){ - u_id=dt.getId(); - } + // if(H5Tget_size(dt.getId())>255){ + // u_id=dt.getId(); + // } + u_id = dt.getId(); if (H5Dread( details::get_dataset(static_cast(this)).getId(), @@ -401,8 +393,8 @@ inline void SliceTraits::write(const T& buffer) { throw DataSpaceException(ss.str()); } - const AtomicType::type> - array_datatype; + // const AtomicType::type> + // array_datatype; auto dt = ds.getDataType(); // Apply pre write convertions bool isTranspose = details::get_dataset(static_cast(this)).isTransposed(); @@ -412,22 +404,33 @@ inline void SliceTraits::write(const T& buffer) { } details::data_converter converter(nocv_buffer, mem_space,dt); - auto u_id=array_datatype.getId();; - if(H5Tget_size(dt.getId())>255){ - u_id=dt.getId(); - } + auto u_id=dt.getId(); + //array_datatype.getId(); + + // if(H5Tget_size(dt.getId())>255){ + // u_id= + // } + + auto tw = static_cast(converter.transform_write(nocv_buffer)); if (H5Dwrite(details::get_dataset(static_cast(this)).getId(), u_id, details::get_memspace_id((static_cast(this))), space.getId(), H5P_DEFAULT, - static_cast( - converter.transform_write(nocv_buffer))) < 0) { + tw) < 0) { HDF5ErrMapper::ToException( "Error during HDF5 Write: "); } } + + + + + + + + template template inline void SliceTraits::write(const T* buffer) { diff --git a/inst/include/highfive/bits/H5Utils.hpp b/inst/include/highfive/bits/H5Utils.hpp index 8c44b8b..5a521d6 100644 --- a/inst/include/highfive/bits/H5Utils.hpp +++ b/inst/include/highfive/bits/H5Utils.hpp @@ -22,9 +22,9 @@ #include #endif - - -#include +#pragma warning(push, 0) +#include +#pragma warning(pop) @@ -33,143 +33,144 @@ namespace HighFive { - namespace details { - -// determine at compile time number of dimensions of in memory datasets -template -struct array_dims { - static const size_t value = 0; -}; - -template -struct array_dims > { - static const size_t value = 1 + array_dims::value; -}; - -template -struct array_dims { - static const size_t value = 1 + array_dims::value; -}; - -template -struct array_dims { - static const size_t value = 1 + array_dims::value; -}; - - - - - template - struct array_dims > { - static const size_t value = (RowsAtCompileTime != 1 ? 1 : 0) + (ColsAtCompileTime != 1 ? 1 : 0); - }; - template - struct array_dims > > { - static const size_t value = (RowsAtCompileTime != 1 ? 1 : 0) + (ColsAtCompileTime != 1 ? 1 : 0); - }; - template - struct array_dims > > { - static const size_t value = (RowsAtCompileTime != 1 ? 1 : 0) + (ColsAtCompileTime != 1 ? 1 : 0); - }; - template - struct array_dims > > { - static const size_t value = (RowsAtCompileTime != 1 ? 1 : 0) + (ColsAtCompileTime != 1 ? 1 : 0); - }; - - template - std::vector - get_dim_vector(const Eigen::Matrix &mat) { - const size_t dim_num = array_dims >::value; - std::vector dims(dim_num); - if (dim_num > 0) { - dims[0] = mat.rows(); - } - if (dim_num > 1) { - dims[1] = mat.cols(); - } - return dims; - } - - template - std::vector - get_dim_vector(const Eigen::Map > &mat) { - const size_t dim_num = array_dims > >::value; - std::vector dims(dim_num); - if (dim_num > 0) { - dims[0] = mat.rows(); - } - if (dim_num > 1) { - dims[1] = mat.cols(); - } - return dims; - } + namespace details { + + // determine at compile time number of dimensions of in memory datasets + template + struct array_dims { + static const size_t value = 0; + }; + + template + struct array_dims > { + static const size_t value = 1 + array_dims::value; + }; + + template + struct array_dims { + static const size_t value = 1 + array_dims::value; + }; + + template + struct array_dims { + static const size_t value = 1 + array_dims::value; + }; + + + + + + template + struct array_dims > { + static const size_t value = (RowsAtCompileTime != 1 ? 1 : 0) + (ColsAtCompileTime != 1 ? 1 : 0); + }; + template + struct array_dims > > { + static const size_t value = (RowsAtCompileTime != 1 ? 1 : 0) + (ColsAtCompileTime != 1 ? 1 : 0); + }; + template + struct array_dims > > { + static const size_t value = (RowsAtCompileTime != 1 ? 1 : 0) + (ColsAtCompileTime != 1 ? 1 : 0); + }; + template + struct array_dims > > { + static const size_t value = (RowsAtCompileTime != 1 ? 1 : 0) + (ColsAtCompileTime != 1 ? 1 : 0); + }; + + template + std::vector + get_dim_vector(const Eigen::Matrix &mat) { + const size_t dim_num = array_dims >::value; + std::vector dims(dim_num); + if (dim_num > 0) { + dims[0] = mat.rows(); + } + if (dim_num > 1) { + dims[1] = mat.cols(); + } + return dims; + } + + template + std::vector + get_dim_vector(const Eigen::Map > &mat) { + const size_t dim_num = array_dims > >::value; + std::vector dims(dim_num); + if (dim_num > 0) { + dims[0] = mat.rows(); + } + if (dim_num > 1) { + dims[1] = mat.cols(); + } + return dims; + } #ifdef H5_USE_BOOST -template -struct array_dims > { - static const size_t value = Dims; -}; - -template -struct array_dims > { - static const size_t value = 2; -}; - -template -struct array_dims > { - static const size_t value = 2; -}; + template + struct array_dims > { + static const size_t value = Dims; + }; + + template + struct array_dims > { + static const size_t value = 2; + }; + + template + struct array_dims > { + static const size_t value = 2; + }; #endif -// determine recursively the size of each dimension of a N dimension vector -template -void get_dim_vector_rec(const T& vec, std::vector& dims) { - (void)dims; - (void)vec; -} + // determine recursively the size of each dimension of a N dimension vector + template + void get_dim_vector_rec(const T& vec, std::vector& dims) { + (void)dims; + (void)vec; + } -template -void get_dim_vector_rec(const std::vector& vec, std::vector& dims) { - dims.push_back(vec.size()); - get_dim_vector_rec(vec[0], dims); -} + template + void get_dim_vector_rec(const std::vector& vec, std::vector& dims) { + dims.push_back(vec.size()); + get_dim_vector_rec(vec[0], dims); + } -template -std::vector get_dim_vector(const std::vector& vec) { - std::vector dims; - get_dim_vector_rec(vec, dims); - return dims; -} + template + std::vector get_dim_vector(const std::vector& vec) { + std::vector dims; + get_dim_vector_rec(vec, dims); + return dims; + } -// determine at compile time recursively the basic type of the data -template -struct type_of_array { - typedef T type; -}; + // determine at compile time recursively the basic type of the data + template + struct type_of_array { + typedef T type; + }; -template -struct type_of_array > { - typedef typename type_of_array::type type; -}; + template + struct type_of_array > { + typedef typename type_of_array::type type; + }; - template - struct type_of_array > { - typedef typename type_of_array::type type; - }; - template - struct type_of_array > > { - typedef typename type_of_array::type type; - }; - template - struct type_of_array > { - typedef typename type_of_array::type type; - }; - template - struct type_of_array > > { - typedef typename type_of_array::type type; - }; + template + struct type_of_array > { + typedef typename type_of_array::type type; + }; + template + struct type_of_array > > { + typedef typename type_of_array::type type; + }; + template + struct type_of_array > { + typedef typename type_of_array::type type; + }; + template + struct type_of_array > > { + typedef typename type_of_array::type type; + }; @@ -177,94 +178,94 @@ struct type_of_array > { #ifdef H5_USE_BOOST -template -struct type_of_array > { - typedef typename type_of_array::type type; -}; - -template -struct type_of_array > { - typedef typename type_of_array::type type; -}; - -template -struct type_of_array > { - typedef typename type_of_array::type type; -}; + template + struct type_of_array > { + typedef typename type_of_array::type type; + }; + + template + struct type_of_array > { + typedef typename type_of_array::type type; + }; + + template + struct type_of_array > { + typedef typename type_of_array::type type; + }; #endif -template -struct type_of_array { - typedef typename type_of_array::type type; -}; - -template -struct type_of_array { - typedef typename type_of_array::type type; -}; - -// same type compile time check -template -struct is_same { - static const bool value = false; -}; - -template -struct is_same { - static const bool value = true; -}; - -// check if the type is a container ( only vector supported for now ) -template -struct is_container { - static const bool value = false; -}; - -template -struct is_container > { - static const bool value = true; -}; - -// check if the type is a basic C-Array -// check if the type is a container ( only vector supported for now ) -template -struct is_c_array { - static const bool value = false; -}; - -template -struct is_c_array { - static const bool value = true; -}; - -template -struct is_c_array { - static const bool value = true; -}; - -// enable if implem for not c++11 compiler -template -struct enable_if {}; - -template -struct enable_if { - typedef T type; -}; - -// remove const -template -struct remove_const { - typedef Type type; -}; - -template -struct remove_const { - typedef Type type; -}; - - - - -} // end details + template + struct type_of_array { + typedef typename type_of_array::type type; + }; + + template + struct type_of_array { + typedef typename type_of_array::type type; + }; + + // same type compile time check + template + struct is_same { + static const bool value = false; + }; + + template + struct is_same { + static const bool value = true; + }; + + // check if the type is a container ( only vector supported for now ) + template + struct is_container { + static const bool value = false; + }; + + template + struct is_container > { + static const bool value = true; + }; + + // check if the type is a basic C-Array + // check if the type is a container ( only vector supported for now ) + template + struct is_c_array { + static const bool value = false; + }; + + template + struct is_c_array { + static const bool value = true; + }; + + template + struct is_c_array { + static const bool value = true; + }; + + // enable if implem for not c++11 compiler + template + struct enable_if {}; + + template + struct enable_if { + typedef T type; + }; + + // remove const + template + struct remove_const { + typedef Type type; + }; + + template + struct remove_const { + typedef Type type; + }; + + + + + } // end details } diff --git a/inst/include/meta/meta.hpp b/inst/include/meta/meta.hpp index 4acd1de..91eedc6 100644 --- a/inst/include/meta/meta.hpp +++ b/inst/include/meta/meta.hpp @@ -21,11 +21,12 @@ #include #include -#if defined(__clang__) +#ifdef __clang__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" #pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wdocumentation-deprecated-sync" +#pragma GCC diagnostic ignored "-Wmissing-variable-declarations" #endif /// \defgroup meta Meta @@ -68,7 +69,7 @@ /// Datatypes. /// \ingroup meta -/// \defgroup list List +/// \defgroup list list_like /// \ingroup datatype /// \defgroup integral Integer sequence @@ -113,3356 +114,3827 @@ /// Tiny metaprogramming library namespace meta { - /// \cond - inline namespace v1 + namespace detail { - /// \endcond - - namespace detail - { - /// Returns a \p T nullptr - template - constexpr T *_nullptr_v() - { - return nullptr; - } - } // namespace detail - - /// An empty type. - /// \ingroup datatype - struct nil_ - { - }; - - /// Type alias for \p T::type. - /// \ingroup invocation - template - using _t = typename T::type; - -#if defined(__cpp_variable_templates) || defined(META_DOXYGEN_INVOKED) - /// Variable alias for \c T::type::value - /// \note Requires C++14 or greater. - /// \ingroup invocation + /// Returns a \p T nullptr template - constexpr typename _t::value_type _v = _t::value; -#endif - - /// Lazy versions of meta actions - namespace lazy + constexpr T *_nullptr_v() { - /// \sa `meta::_t` - /// \ingroup lazy_invocation - template - using _t = defer<_t, T>; + return nullptr; } - /// An integral constant wrapper for \c std::size_t. - /// \ingroup integral - template - using size_t = std::integral_constant; - - /// An integral constant wrapper for \c bool. - /// \ingroup integral - template - using bool_ = std::integral_constant; +#if META_CXX_VARIABLE_TEMPLATES + template + META_INLINE_VAR constexpr T *nullptr_v = nullptr; +#endif + } // namespace detail - /// An integral constant wrapper for \c int. - /// \ingroup integral - template - using int_ = std::integral_constant; + /// An empty type. + /// \ingroup datatype + struct nil_ + { + }; + + /// Type alias for \p T::type. + /// \ingroup invocation + template + using _t = typename T::type; + +#if META_CXX_VARIABLE_TEMPLATES || defined(META_DOXYGEN_INVOKED) + /// Variable alias for \c T::type::value + /// \note Requires C++14 or greater. + /// \ingroup invocation + template + constexpr typename T::type::value_type _v = T::type::value; +#endif - /// An integral constant wrapper for \c char. - /// \ingroup integral - template - using char_ = std::integral_constant; - - /////////////////////////////////////////////////////////////////////////////////////////// - // Math operations - /// An integral constant wrapper around the result of incrementing the wrapped - /// integer \c - /// T::type::value. + /// Lazy versions of meta actions + namespace lazy + { + /// \sa `meta::_t` + /// \ingroup lazy_invocation + template + using _t = defer<_t, T>; + } // namespace lazy + + /// An integral constant wrapper for \c std::size_t. + /// \ingroup integral + template + using size_t = std::integral_constant; + + /// An integral constant wrapper for \c bool. + /// \ingroup integral + template + using bool_ = std::integral_constant; + + /// An integral constant wrapper for \c int. + /// \ingroup integral + template + using int_ = std::integral_constant; + + /// An integral constant wrapper for \c char. + /// \ingroup integral + template + using char_ = std::integral_constant; + + /////////////////////////////////////////////////////////////////////////////////////////// + // Math operations + /// An integral constant wrapper around the result of incrementing the wrapped integer \c + /// T::type::value. + template + using inc = std::integral_constant; + + /// An integral constant wrapper around the result of decrementing the wrapped integer \c + /// T::type::value. + template + using dec = std::integral_constant; + + /// An integral constant wrapper around the result of adding the two wrapped integers + /// \c T::type::value and \c U::type::value. + /// \ingroup math + template + using plus = std::integral_constant; + + /// An integral constant wrapper around the result of subtracting the two wrapped integers + /// \c T::type::value and \c U::type::value. + /// \ingroup math + template + using minus = std::integral_constant; + + /// An integral constant wrapper around the result of multiplying the two wrapped integers + /// \c T::type::value and \c U::type::value. + /// \ingroup math + template + using multiplies = std::integral_constant; + + /// An integral constant wrapper around the result of dividing the two wrapped integers \c + /// T::type::value and \c U::type::value. + /// \ingroup math + template + using divides = std::integral_constant; + + /// An integral constant wrapper around the result of negating the wrapped integer + /// \c T::type::value. + /// \ingroup math + template + using negate = std::integral_constant; + + /// An integral constant wrapper around the remainder of dividing the two wrapped integers + /// \c T::type::value and \c U::type::value. + /// \ingroup math + template + using modulus = std::integral_constant; + + /// A Boolean integral constant wrapper around the result of comparing \c T::type::value and + /// \c U::type::value for equality. + /// \ingroup math + template + using equal_to = bool_; + + /// A Boolean integral constant wrapper around the result of comparing \c T::type::value and + /// \c U::type::value for inequality. + /// \ingroup math + template + using not_equal_to = bool_; + + /// A Boolean integral constant wrapper around \c true if \c T::type::value is greater than + /// \c U::type::value; \c false, otherwise. + /// \ingroup math + template + using greater = bool_<(T::type::value > U::type::value)>; + + /// A Boolean integral constant wrapper around \c true if \c T::type::value is less than \c + /// U::type::value; \c false, otherwise. + /// \ingroup math + template + using less = bool_<(T::type::value < U::type::value)>; + + /// A Boolean integral constant wrapper around \c true if \c T::type::value is greater than + /// or equal to \c U::type::value; \c false, otherwise. + /// \ingroup math + template + using greater_equal = bool_<(T::type::value >= U::type::value)>; + + /// A Boolean integral constant wrapper around \c true if \c T::type::value is less than or + /// equal to \c U::type::value; \c false, otherwise. + /// \ingroup math + template + using less_equal = bool_<(T::type::value <= U::type::value)>; + + /// An integral constant wrapper around the result of bitwise-and'ing the two wrapped + /// integers \c T::type::value and \c U::type::value. + /// \ingroup math + template + using bit_and = std::integral_constant; + + /// An integral constant wrapper around the result of bitwise-or'ing the two wrapped + /// integers \c T::type::value and \c U::type::value. + /// \ingroup math + template + using bit_or = std::integral_constant; + + /// An integral constant wrapper around the result of bitwise-exclusive-or'ing the two + /// wrapped integers \c T::type::value and \c U::type::value. + /// \ingroup math + template + using bit_xor = std::integral_constant; + + /// An integral constant wrapper around the result of bitwise-complementing the wrapped + /// integer \c T::type::value. + /// \ingroup math + template + using bit_not = std::integral_constant; + + namespace lazy + { + /// \sa 'meta::int' + /// \ingroup lazy_math template - using inc = std::integral_constant; + using inc = defer; - /// An integral constant wrapper around the result of decrementing the wrapped - /// integer \c - /// T::type::value. + /// \sa 'meta::dec' + /// \ingroup lazy_math template - using dec = std::integral_constant; + using dec = defer; - /// An integral constant wrapper around the result of adding the two wrapped - /// integers - /// \c T::type::value and \c U::type::value. - /// \ingroup math + /// \sa 'meta::plus' + /// \ingroup lazy_math template - using plus = std::integral_constant; + using plus = defer; - /// An integral constant wrapper around the result of subtracting the two - /// wrapped integers - /// \c T::type::value and \c U::type::value. - /// \ingroup math + /// \sa 'meta::minus' + /// \ingroup lazy_math template - using minus = std::integral_constant; + using minus = defer; - /// An integral constant wrapper around the result of multiplying the two - /// wrapped integers - /// \c T::type::value and \c U::type::value. - /// \ingroup math + /// \sa 'meta::multiplies' + /// \ingroup lazy_math template - using multiplies = std::integral_constant; + using multiplies = defer; - /// An integral constant wrapper around the result of dividing the two wrapped - /// integers \c - /// T::type::value and \c U::type::value. - /// \ingroup math + /// \sa 'meta::divides' + /// \ingroup lazy_math template - using divides = std::integral_constant; + using divides = defer; - /// An integral constant wrapper around the result of negating the wrapped - /// integer - /// \c T::type::value. - /// \ingroup math + /// \sa 'meta::negate' + /// \ingroup lazy_math template - using negate = std::integral_constant; + using negate = defer; - /// An integral constant wrapper around the remainder of dividing the two - /// wrapped integers - /// \c T::type::value and \c U::type::value. - /// \ingroup math + /// \sa 'meta::modulus' + /// \ingroup lazy_math template - using modulus = std::integral_constant; + using modulus = defer; - /// A Boolean integral constant wrapper around the result of comparing \c - /// T::type::value and - /// \c U::type::value for equality. - /// \ingroup math + /// \sa 'meta::equal_to' + /// \ingroup lazy_math template - using equal_to = bool_; + using equal_to = defer; - /// A Boolean integral constant wrapper around the result of comparing \c - /// T::type::value and - /// \c U::type::value for inequality. - /// \ingroup math + /// \sa 'meta::not_equal_t' + /// \ingroup lazy_math template - using not_equal_to = bool_; + using not_equal_to = defer; - /// A Boolean integral constant wrapper around \c true if \c T::type::value is - /// greater than - /// \c U::type::value; \c false, otherwise. - /// \ingroup math + /// \sa 'meta::greater' + /// \ingroup lazy_math template - using greater = bool_<(T::type::value > U::type::value)>; + using greater = defer; - /// A Boolean integral constant wrapper around \c true if \c T::type::value is - /// less than \c - /// U::type::value; \c false, otherwise. - /// \ingroup math + /// \sa 'meta::less' + /// \ingroup lazy_math template - using less = bool_<(T::type::value < U::type::value)>; + using less = defer; - /// A Boolean integral constant wrapper around \c true if \c T::type::value is - /// greater than - /// or equal to \c U::type::value; \c false, otherwise. - /// \ingroup math + /// \sa 'meta::greater_equal' + /// \ingroup lazy_math template - using greater_equal = bool_<(T::type::value >= U::type::value)>; + using greater_equal = defer; - /// A Boolean integral constant wrapper around \c true if \c T::type::value is - /// less than or - /// equal to \c U::type::value; \c false, otherwise. - /// \ingroup math + /// \sa 'meta::less_equal' + /// \ingroup lazy_math template - using less_equal = bool_<(T::type::value <= U::type::value)>; + using less_equal = defer; - /// An integral constant wrapper around the result of bitwise-and'ing the two - /// wrapped - /// integers \c T::type::value and \c U::type::value. - /// \ingroup math + /// \sa 'meta::bit_and' + /// \ingroup lazy_math template - using bit_and = std::integral_constant; + using bit_and = defer; - /// An integral constant wrapper around the result of bitwise-or'ing the two - /// wrapped - /// integers \c T::type::value and \c U::type::value. - /// \ingroup math + /// \sa 'meta::bit_or' + /// \ingroup lazy_math template - using bit_or = std::integral_constant; + using bit_or = defer; - /// An integral constant wrapper around the result of bitwise-exclusive-or'ing - /// the two - /// wrapped integers \c T::type::value and \c U::type::value. - /// \ingroup math + /// \sa 'meta::bit_xor' + /// \ingroup lazy_math template - using bit_xor = std::integral_constant; + using bit_xor = defer; - /// An integral constant wrapper around the result of bitwise-complementing the - /// wrapped - /// integer \c T::type::value. - /// \ingroup math + /// \sa 'meta::bit_not' + /// \ingroup lazy_math template - using bit_not = std::integral_constant; + using bit_not = defer; + } // namespace lazy - namespace lazy + /// \cond + namespace detail + { + enum class indices_strategy_ { - /// \sa 'meta::int' - /// \ingroup lazy_math - template - using inc = defer; + done, + repeat, + recurse + }; - /// \sa 'meta::dec' - /// \ingroup lazy_math - template - using dec = defer; - - /// \sa 'meta::plus' - /// \ingroup lazy_math - template - using plus = defer; - - /// \sa 'meta::minus' - /// \ingroup lazy_math - template - using minus = defer; - - /// \sa 'meta::multiplies' - /// \ingroup lazy_math - template - using multiplies = defer; - - /// \sa 'meta::divides' - /// \ingroup lazy_math - template - using divides = defer; - - /// \sa 'meta::negate' - /// \ingroup lazy_math - template - using negate = defer; - - /// \sa 'meta::modulus' - /// \ingroup lazy_math - template - using modulus = defer; - - /// \sa 'meta::equal_to' - /// \ingroup lazy_math - template - using equal_to = defer; - - /// \sa 'meta::not_equal_t' - /// \ingroup lazy_math - template - using not_equal_to = defer; - - /// \sa 'meta::greater' - /// \ingroup lazy_math - template - using greater = defer; - - /// \sa 'meta::less' - /// \ingroup lazy_math - template - using less = defer; - - /// \sa 'meta::greater_equal' - /// \ingroup lazy_math - template - using greater_equal = defer; - - /// \sa 'meta::less_equal' - /// \ingroup lazy_math - template - using less_equal = defer; - - /// \sa 'meta::bit_and' - /// \ingroup lazy_math - template - using bit_and = defer; - - /// \sa 'meta::bit_or' - /// \ingroup lazy_math - template - using bit_or = defer; - - /// \sa 'meta::bit_xor' - /// \ingroup lazy_math - template - using bit_xor = defer; - - /// \sa 'meta::bit_not' - /// \ingroup lazy_math - template - using bit_not = defer; + constexpr indices_strategy_ strategy_(std::size_t cur, std::size_t end) + { + return cur >= end ? indices_strategy_::done + : cur * 2 <= end ? indices_strategy_::repeat + : indices_strategy_::recurse; } - /// \cond - namespace detail + template + constexpr std::size_t range_distance_(T begin, T end) { - enum class indices_strategy_ - { - done, - repeat, - recurse - }; - - constexpr indices_strategy_ strategy_(std::size_t cur, std::size_t end) - { - return cur >= end ? indices_strategy_::done - : cur * 2 <= end ? indices_strategy_::repeat - : indices_strategy_::recurse; - } - - template - constexpr std::size_t range_distance_(T begin, T end) - { - return begin <= end ? static_cast(end - begin) - : throw "The start of the integer_sequence must not be " - "greater than the end"; - } - - template - struct make_indices_ - { - using type = State; - }; - - template - struct coerce_indices_ - { - }; + return begin <= end ? static_cast(end - begin) + : throw "The start of the integer_sequence must not be " + "greater than the end"; } -/// \endcond -/////////////////////////////////////////////////////////////////////////////////////////////// -// integer_sequence -#ifndef __cpp_lib_integer_sequence - /// A container for a sequence of compile-time integer constants. - /// \ingroup integral - template - struct integer_sequence + template + struct make_indices_ { - using value_type = T; - /// \return `sizeof...(Is)` - static constexpr std::size_t size() noexcept { return sizeof...(Is); } + using type = State; }; -#endif - /////////////////////////////////////////////////////////////////////////////////////////////// - // index_sequence - /// A container for a sequence of compile-time integer constants of type - /// \c std::size_t - /// \ingroup integral - template - using index_sequence = integer_sequence; - -#if !defined(META_DOXYGEN_INVOKED) && \ - ((defined(__clang__) && __clang_major__ >= 3 && __clang_minor__ >= 8) || \ - (defined(_MSC_VER) && _MSC_FULL_VER >= 190023918)) - // Implement make_integer_sequence and make_index_sequence with the - // __make_integer_seq builtin on compilers that provide it. (Redirect - // through decltype to workaround suspected clang bug.) - /// \cond - namespace detail + template + struct coerce_indices_ { - template - __make_integer_seq make_integer_sequence_(); - } - /// \endcond + }; + } // namespace detail + /// \endcond + + /////////////////////////////////////////////////////////////////////////////////////////// + // integer_sequence +#if !META_CXX_INTEGER_SEQUENCE + /// A container for a sequence of compile-time integer constants. + /// \ingroup integral + template + struct integer_sequence + { + using value_type = T; + /// \return `sizeof...(Is)` + static constexpr std::size_t size() noexcept { return sizeof...(Is); } + }; +#endif + /////////////////////////////////////////////////////////////////////////////////////////// + // index_sequence + /// A container for a sequence of compile-time integer constants of type + /// \c std::size_t + /// \ingroup integral + template + using index_sequence = integer_sequence; + +#if META_HAS_MAKE_INTEGER_SEQ && !defined(META_DOXYGEN_INVOKED) + // Implement make_integer_sequence and make_index_sequence with the + // __make_integer_seq builtin on compilers that provide it. (Redirect + // through decltype to workaround suspected clang bug.) + /// \cond + namespace detail + { template - using make_integer_sequence = decltype(detail::make_integer_sequence_()); + __make_integer_seq make_integer_sequence_(); + } + /// \endcond - template - using make_index_sequence = make_integer_sequence; -#else - /// Generate \c index_sequence containing integer constants [0,1,2,...,N-1]. - /// \par Complexity - /// \f$ O(log(N)) \f$. - /// \ingroup integral - template - using make_index_sequence = - _t, detail::strategy_(1, N)>>; + template + using make_integer_sequence = decltype(detail::make_integer_sequence_()); - /// Generate \c integer_sequence containing integer constants [0,1,2,...,N-1]. - /// \par Complexity - /// \f$ O(log(N)) \f$. - /// \ingroup integral - template - using make_integer_sequence = - _t(N)>>>; + template + using make_index_sequence = make_integer_sequence; +#else + /// Generate \c index_sequence containing integer constants [0,1,2,...,N-1]. + /// \par Complexity + /// \f$ O(log(N)) \f$. + /// \ingroup integral + template + using make_index_sequence = + _t, detail::strategy_(1, N)>>; + + /// Generate \c integer_sequence containing integer constants [0,1,2,...,N-1]. + /// \par Complexity + /// \f$ O(log(N)) \f$. + /// \ingroup integral + template + using make_integer_sequence = + _t(N)>>>; #endif - /////////////////////////////////////////////////////////////////////////////////////////////// - // integer_range - /// Makes the integer sequence [From, To). - /// \par Complexity - /// \f$ O(log(To - From)) \f$. - /// \ingroup integral - template - using integer_range = - _t>>; + /////////////////////////////////////////////////////////////////////////////////////////// + // integer_range + /// Makes the integer sequence [From, To). + /// \par Complexity + /// \f$ O(log(To - From)) \f$. + /// \ingroup integral + template + using integer_range = + _t>>; - /// \cond - namespace detail + /// \cond + namespace detail + { + template + struct concat_indices_ { - template - struct concat_indices_ - { - }; - - template - struct concat_indices_, index_sequence> - { - using type = index_sequence; - }; - - template <> - struct make_indices_<0u, index_sequence<0>, indices_strategy_::done> - { - using type = index_sequence<>; - }; - - template - struct make_indices_, indices_strategy_::repeat> - : make_indices_, - detail::strategy_(sizeof...(Values)*2, End)> - { - }; - - template - struct make_indices_, indices_strategy_::recurse> - : concat_indices_, - make_index_sequence> - { - }; - - template - struct coerce_indices_> - { - using type = - integer_sequence(static_cast(Values) + Offset)...>; - }; - } // namespace detail - /// \endcond - - /// Evaluate the Callable \p F with the arguments \p Args. - /// \ingroup invocation - template - using invoke = typename F::template invoke; + }; - /// Lazy versions of meta actions - namespace lazy + template + struct concat_indices_, index_sequence> { - /// \sa `meta::invoke` - /// \ingroup lazy_invocation - template - using invoke = defer; - } + using type = index_sequence; + }; - /// A trait that always returns its argument \p T. Also, a Callable that always - /// returns - /// \p T. - /// \ingroup trait - /// \ingroup invocation - template - struct id + template <> + struct make_indices_<0u, index_sequence<0>, indices_strategy_::done> { -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 && !defined(META_DOXYGEN_INVOKED) - // Redirect through decltype for compilers that have not - // yet implemented CWG 1558: - // - static id impl(void *); - - template - using invoke = _t *>(nullptr)))>; -#else - template - using invoke = T; -#endif + using type = index_sequence<>; + }; - using type = T; + template + struct make_indices_, indices_strategy_::repeat> + : make_indices_, + detail::strategy_(sizeof...(Values) * 2, End)> + { }; - /// An alias for type \p T. Useful in non-deduced contexts. - /// \ingroup trait - template - using id_t = _t>; + template + struct make_indices_, indices_strategy_::recurse> + : concat_indices_, + make_index_sequence> + { + }; - namespace lazy + template + struct coerce_indices_> { - /// \sa `meta::id` - /// \ingroup lazy_trait - /// \ingroup lazy_invocation - template - using id = defer; - } + using type = + integer_sequence(static_cast(Values) + Offset)...>; + }; + } // namespace detail + /// \endcond + + /// Evaluate the invocable \p Fn with the arguments \p Args. + /// \ingroup invocation + template + using invoke = typename Fn::template invoke; - /// An alias for `void`. - /// \ingroup trait -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 && !defined(META_DOXYGEN_INVOKED) + /// Lazy versions of meta actions + namespace lazy + { + /// \sa `meta::invoke` + /// \ingroup lazy_invocation + template + using invoke = defer; + } // namespace lazy + + /// A trait that always returns its argument \p T. It is also an invocable + /// that always returns \p T. + /// \ingroup trait + /// \ingroup invocation + template + struct id + { +#if defined(META_WORKAROUND_CWG_1558) && !defined(META_DOXYGEN_INVOKED) // Redirect through decltype for compilers that have not // yet implemented CWG 1558: - // + static id impl(void *); + template - using void_ = invoke, Ts...>; + using invoke = _t *>(nullptr)))>; #else template - using void_ = void; + using invoke = T; #endif - /// \cond - namespace detail - { - template - struct is_trait_ - { - using type = std::false_type; - }; - - template - struct is_trait_> - { - using type = std::true_type; - }; - - template - struct is_callable_ - { - using type = std::false_type; - }; - - template - struct is_callable_>> - { - using type = std::true_type; - }; + using type = T; + }; - template