print_container.hpp

来自「Boost provides free peer-reviewed portab」· HPP 代码 · 共 65 行

HPP
65
字号
////////////////////////////////////////////////////////////////////////////////// (C) Copyright Ion Gaztanaga 2004-2007. Distributed under the Boost// Software License, Version 1.0. (See accompanying file// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)//// See http://www.boost.org/libs/interprocess for documentation.////////////////////////////////////////////////////////////////////////////////#ifndef BOOST_PRINTCONTAINER_HPP#define BOOST_PRINTCONTAINER_HPP#include <boost/interprocess/detail/config_begin.hpp>#include <functional>#include <iostream>#include <algorithm>namespace boost{namespace interprocess{namespace test{struct PrintValues : public std::unary_function<int, void>{   void operator() (int value) const   {      std::cout << value << " ";   }};template<class Container>void PrintContents(const Container &cont, const char *contName){   std::cout<< "Printing contents of " << contName << std::endl;   std::for_each(cont.begin(), cont.end(), PrintValues());   std::cout<< std::endl << std::endl;}//Function to dump datatemplate<class MyShmCont        ,class MyStdCont>void PrintContainers(MyShmCont *shmcont, MyStdCont *stdcont){   typename MyShmCont::iterator itshm = shmcont->begin(), itshmend = shmcont->end();   typename MyStdCont::iterator itstd = stdcont->begin(), itstdend = stdcont->end();   std::cout << "MyShmCont" << std::endl;   for(; itshm != itshmend; ++itshm){      std::cout << *itshm << std::endl;   }   std::cout << "MyStdCont" << std::endl;      for(; itstd != itstdend; ++itstd){      std::cout << *itstd << std::endl;   }}}  //namespace test{}  //namespace interprocess{}  //namespace boost{#include <boost/interprocess/detail/config_end.hpp>#endif //#ifndef BOOST_PRINTCONTAINER_HPP

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?