Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/nntpchan-daemon/libmustache/visitor/is_node_empty.hpp
2017-10-11 09:48:27 -04:00

42 lines
706 B
C++

#pragma once
#include <boost/variant/static_visitor.hpp>
#include "mstch/mstch.hpp"
namespace mstch {
class is_node_empty: public boost::static_visitor<bool> {
public:
template<class T>
bool operator()(const T&) const {
return false;
}
bool operator()(const std::nullptr_t&) const {
return true;
}
bool operator()(const int& value) const {
return value == 0;
}
bool operator()(const double& value) const {
return value == 0;
}
bool operator()(const bool& value) const {
return !value;
}
bool operator()(const std::string& value) const {
return value == "";
}
bool operator()(const array& array) const {
return array.size() == 0;
}
};
}