Skip to content
Snippets Groups Projects
Commit 03189d38 authored by Thomas Kennedy's avatar Thomas Kennedy
Browse files

Update C++ Input Library based on discussion

parent 4d29f78c
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ MAINPROG=parseTemps
SOURCES:=$(wildcard *.cpp)
OBJECTS=$(SOURCES:.cpp=.o)
FLAGS=-std=c++11 -fsanitize=address,leak,undefined -Wall -Wextra -fuse-ld=gold
FLAGS=-std=c++17 -fsanitize=address,leak,undefined -Wall -Wextra -fuse-ld=gold
all: $(SOURCES) $(MAINPROG)
......
......@@ -2,6 +2,7 @@
#define PARSE_TEMPS_H_INCLUDED
#include <iostream>
#include <sstream>
#include <iterator>
#include <algorithm>
#include <utility>
......@@ -17,7 +18,7 @@ using CoreTempReading = std::pair<int, std::vector<double>>;
/**
* Take an input file and time-step size and parse all core temps.
*
* @tparam CoreTempReadingContainer type of container to use (it must implement
* @tparam Container type of container to use (it must implement
* push_back and emplace_back)
*
* @param original_temps an input file
......@@ -26,11 +27,11 @@ using CoreTempReading = std::pair<int, std::vector<double>>;
* @return a vector of 2-tuples (pairs) containing time step and core
* temperature readings
*/
template<typename CoreTempReadingContainer>
CoreTempReadingContainer parse_raw_temps(std::istream& original_temps,
int step_size = 30)
template<template<typename...> class Container>
Container<CoreTempReading> parse_raw_temps(std::istream& original_temps,
int step_size = 30)
{
CoreTempReadingContainer allTheReadings;
Container<CoreTempReading> allTheReadings;
// Input Parsing Variables
int step = 0;
......
......@@ -3,10 +3,6 @@
#include <fstream>
#include <vector>
#include <list>
#include <sstream>
#include <memory>
#include <iterator>
#include <algorithm>
#include <utility>
#include "parseTemps.h"
......@@ -30,7 +26,7 @@ int main(int argc, char** argv)
// End Input Validation
// vector
auto readings = parse_raw_temps<std::vector<CoreTempReading>>(input_temps);
auto readings = parse_raw_temps<std::vector>(input_temps);
// list
// auto readings = parse_raw_temps<std::list<CoreTempReading>>(input_temps);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment