summaryrefslogtreecommitdiff
path: root/src/support/file.cpp
diff options
context:
space:
mode:
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;