summaryrefslogtreecommitdiff
path: root/src/support/file.cpp
diff options
context:
space:
mode:
authorJF Bastien <jfb@chromium.org>2016-01-13 10:48:44 -0800
committerJF Bastien <jfb@chromium.org>2016-01-13 10:48:44 -0800
commit80d0b8eb31b1bb15ecd2245ef6ad57ca4d3a2575 (patch)
treed6dc07b081ed5c7e3a44bf1827c9b7d285d1a456 /src/support/file.cpp
parent2a0404579a2c061a965e2ac032801e250ab7f2bc (diff)
parent3da40ef949ddfac78df2db33e6b35e14f54cb78c (diff)
downloadbinaryen-80d0b8eb31b1bb15ecd2245ef6ad57ca4d3a2575.tar.gz
binaryen-80d0b8eb31b1bb15ecd2245ef6ad57ca4d3a2575.tar.bz2
binaryen-80d0b8eb31b1bb15ecd2245ef6ad57ca4d3a2575.zip
Merge branch 'master' of github.com:WebAssembly/binaryen
Diffstat (limited to 'src/support/file.cpp')
-rw-r--r--src/support/file.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/support/file.cpp b/src/support/file.cpp
index 470d07737..8813750d4 100644
--- a/src/support/file.cpp
+++ b/src/support/file.cpp
@@ -18,7 +18,8 @@
#include <cstdlib>
-std::string wasm::read_file(const std::string &filename, bool debug) {
+template <typename T>
+T wasm::read_file(const std::string &filename, bool debug) {
if (debug) std::cerr << "Loading '" << filename << "'..." << std::endl;
std::ifstream infile(filename);
if (!infile.is_open()) {
@@ -27,12 +28,16 @@ std::string wasm::read_file(const std::string &filename, bool debug) {
}
infile.seekg(0, std::ios::end);
size_t insize = infile.tellg();
- std::string input(insize + 1, '\0');
+ T input(insize + 1, '\0');
infile.seekg(0);
infile.read(&input[0], insize);
return input;
}
+// Explicit instantiations for the explicit specializations.
+template std::string wasm::read_file<>(const std::string &, bool);
+template std::vector<char> wasm::read_file<>(const std::string &, bool);
+
wasm::Output::Output(const std::string &filename, bool debug)
: outfile(), out([this, filename, debug]() {
std::streambuf *buffer;