Multi-user gravity beats for Sound of Science 2013 (server)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 

27 lines
528 B

#pragma once
#include "json.h"
struct Identity{
template <typename T>
T operator()(T t) const {
return t;
}
};
struct All{
template <typename T>
bool operator()(T const & t) const {
return true;
}
};
template <typename C, typename F1 = Identity, typename F2 = All>
inline js::Value vector_to_json(C const & container, F1 const & transform = Identity(), F2 const & filter = All()){
js::Array array;
for(auto x : container){
if(!filter(x)) continue;
array.push_back(to_json(transform(x)));
}
return array;
}