/*******************************************************************************
*
* TRIQS: a Toolbox for Research in Interacting Quantum Systems
*
* Copyright (C) 2012 by O. Parcollet
*
* TRIQS is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* TRIQS. If not, see .
*
******************************************************************************/
#ifndef TRIQS_CLEF_IO_H
#define TRIQS_CLEF_IO_H
#include "../clef.hpp"
#include
namespace triqs { namespace clef {
/* ---------------------------------------------------------------------------------------------------
* Printing of the expressions
* --------------------------------------------------------------------------------------------------- */
template std::ostream &operator <<(std::ostream &sout, placeholder ){return sout << "_"< std::ostream & operator<<(std::ostream & out, std::reference_wrapper const & x) { return out<< x.get(); }
inline std::ostream & variadic_print(std::ostream& out) { return out; }
template std::ostream & variadic_print(std::ostream& out, T0&& t0, T&&... t)
{ out<< t0<<( sizeof...(T)>0 ? ", ": ""); variadic_print (out, t...); return out;}
template struct print_tuple_impl {
template void operator() (std::ostream& out, Tuple const & t) { out << std::get(t) << (c!=m-1 ? ", ": ""); print_tuple_impl()(out, t); }
};
template struct print_tuple_impl {
template void operator() (std::ostream& out, Tuple const & t) {}
};
template std::ostream & print_tuple(std::ostream& out, Tuple const & t) {
print_tuple_impl<1,std::tuple_size::value>()(out,t); return out;
}
template
typename std::enable_if::value, std::ostream &>::type
operator <<(std::ostream &sout, expr const &ex){
return sout << "("<< Tag::name() <<" "<(ex.childs)<<")" ;
}
template
typename std::enable_if::value, std::ostream &>::type
operator <<(std::ostream &sout, expr const &ex){
return sout << "("<(ex.childs) <<" "<< Tag::name() <<" "<(ex.childs)<<")" ;
}
template std::ostream &operator <<(std::ostream &sout, expr const &ex){
return sout << "(" << std::get<0>(ex.childs) << "?"<< std::get<1>(ex.childs) <<" : "<< std::get<2>(ex.childs) <<")";
}
template std::ostream &operator <<(std::ostream &sout, expr const &ex){
sout << std::get<0>(ex.childs) << "("; print_tuple(sout,ex.childs); return sout<<")" ;
}
template std::ostream &operator <<(std::ostream &sout, expr const &ex){
sout << std::get<0>(ex.childs) << "["; print_tuple(sout,ex.childs); return sout<<"]" ;
}
template std::ostream &operator <<(std::ostream &sout,
expr const &ex) {return sout << std::get<0>(ex.childs) ; }
template std::ostream &operator <<(std::ostream &sout,
expr const &ex) {return sout << std::get<0>(ex.childs) << "["<(ex.childs)<<"]" ; }
template std::ostream &operator <<(std::ostream &sout,
expr const &ex) {return sout << "-("<(ex.childs) <<")" ; }
template< typename Expr, int... Is>
std::ostream &operator <<(std::ostream &sout, make_fun_impl const & x) {
sout << "lazy function : ("; variadic_print(sout, placeholder()...); return sout<< ") --> "<< x.ex ;
}
template std::ostream & operator<<(std::ostream & out, function const & x) { return out<<"function ";}
}}
#endif