MSVC support

This commit is contained in:
Daniel Sipka 2015-09-24 11:43:27 +02:00
parent bce9d570ba
commit 87912c46db
5 changed files with 15 additions and 8 deletions

View File

@ -1,7 +1,13 @@
cmake_minimum_required(VERSION 2.8)
project(mstch)
option (WITH_UNIT_TESTS "enable building unit test executable" OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O3")
set(CMAKE_BUILD_TYPE Release)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O3")
endif()
add_subdirectory(src)
if(WITH_UNIT_TESTS)
enable_testing()

View File

@ -4,6 +4,7 @@
#include <map>
#include <string>
#include <memory>
#include <functional>
#include <boost/variant.hpp>
@ -20,7 +21,7 @@ class object_t {
}
bool has(const std::string name) const {
return methods.count(name);
return methods.count(name) != 0;
}
protected:

View File

@ -25,7 +25,7 @@ std::string render_context::push::render(const template_type& templt) {
render_context::render_context(
const mstch::node& node,
const std::map<std::string, template_type>& partials):
partials{partials}, nodes{node}
partials(partials), nodes(1, node)
{
state.push(std::unique_ptr<render_state>(new outside_section));
}

View File

@ -23,7 +23,7 @@ void template_type::tokenize(const std::string& tmp) {
citer beg = tmp.begin();
auto npos = std::string::npos;
for (unsigned long cur_pos = 0; cur_pos < tmp.size();) {
for (unsigned long long cur_pos = 0; cur_pos < tmp.size();) {
auto open_pos = tmp.find(open, cur_pos);
auto close_pos = tmp.find(
close, open_pos == npos ? open_pos : open_pos + 1);

View File

@ -3,9 +3,9 @@
#include <chrono>
#include <iostream>
unsigned long current_msec() {
return std::chrono::system_clock::now().time_since_epoch() /
std::chrono::milliseconds(1);
unsigned long long current_msec() {
return std::chrono::time_point_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now()).time_since_epoch().count();
}
int main() {
@ -25,7 +25,7 @@ int main() {
}}
};
std::vector<unsigned long> times;
std::vector<unsigned long long> times;
for (int j = 0; j < 10; j++) {
auto start = current_msec();
for (int i = 0; i < 5000; i++)