Skip to content

Commit

Permalink
[FIX] ambiguous call
Browse files Browse the repository at this point in the history
Clash with std::format
  • Loading branch information
eseiler committed Jul 21, 2023
1 parent efbeef7 commit 18d5e3a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tutorial/csx-printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <sdsl/cst_sct3.hpp>

using namespace sdsl;
using namespace std;

std::string format("%3I%3S %3s %3P %3p %3L %3B %T");
std::string header(" i SA ISA PSI LF LCP BWT TEXT");
Expand All @@ -19,19 +18,19 @@ typedef cst_sct3<csa_int_t> cst_int_t;

void print_usage(char const * command)
{
cout << "\
std::cout << "\
A pretty printer for suffix array/tree members.\n\
Transforms each input line into a CST and outputs\n\
formatted suffix array/tree members.\n\
Usage: " << command
<< " X \"[FORMAT]\" \"[HEADER]\" \"[SENTINEL]\"\n\
<< " X \"[FORMAT]\" \"[HEADER]\" \"[SENTINEL]\"\n\
X : Input is interpreted dependent on X.\n\
X=1: byte sequence.\n\
X=d: sequence of decimal numbers.\n\
FORMAT : Format string. Default=`"
<< format << "`.\n\
<< format << "`.\n\
HEADER : Header string. Default=`"
<< header << "`.\n\
<< header << "`.\n\
SENTINEL: Sentinel character. \n\
\n\
Each line of the output will be formatted according to the format string.\
Expand Down Expand Up @@ -68,24 +67,24 @@ int main(int argc, char * argv[])
{
header = argv[3];
}
while (cin.getline(line, BUF_SIZE))
while (std::cin.getline(line, BUF_SIZE))
{
cout << header << endl;
std::cout << header << std::endl;
if ('1' == argv[1][0])
{
cst_byte_t cst;
construct_im(cst, (char const *)line, 1);
stringstream ss;
std::stringstream ss;
csXprintf(ss, format, cst, ((argc > 4) ? argv[4][0] : '$'));
std::string line(ss.str());
cout << std::regex_replace(line, std::regex(R"(\$)"), "\\$") << endl;
std::cout << std::regex_replace(line, std::regex(R"(\$)"), "\\$") << std::endl;
}
else if ('d' == argv[1][0])
{
cst_int_t cst;
construct_im(cst, (char const *)line, 'd');
csXprintf(cout, format, cst, ((argc > 4) ? argv[4][0] : '0'));
csXprintf(std::cout, format, cst, ((argc > 4) ? argv[4][0] : '0'));
}
cout << endl;
std::cout << std::endl;
}
}

0 comments on commit 18d5e3a

Please sign in to comment.