boost
をテンプレートにして作成
[
トップ
|
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
-----
#contents
-----
**[[boost::bind:http://boost.cppll.jp/HEAD/libs/bind/bind...
#include <boost/bind.hpp>
#code(C){{
int func2(int x, int y)
{
return x+y;
}
int func3(int x, int y, int z)
{
return x+y+z;
}
void main(void)
{
boost::function<int (int, int)> func;
func = func2;
cout << func(1, 2) << endl;
func = boost::bind(func3, _1, _2, 0);
cout << func(1, 2) << endl;
}
}}
#code(C){{
Class1 *obj = new Class1;
boost::function<int (int)> func = boost::bind(&Class1::Fu...
}}
**[[boost::mem_fn:http://boost.cppll.jp/HEAD/libs/bind/me...
#include<boost/mem_fn.hpp>
class MemClass
{
public:
MemClass(int x) : a(x){}
void Print(){ cout << a << endl; }
private:
int a;
};
void main(void)
{
vector<MemClass> v;
v.push_back(MemClass(1));
v.push_back(MemClass(2));
v.push_back(MemClass(3));
for_each(v.begin(), v.end(), boost::mem_fn(&MemClass:...
}
**[[boost::lexical_cast:http://boost.cppll.jp/HEAD/libs/c...
#include<boost/lexical_cast.hpp>
double x = 0.0;
std::string str;
str = boost::lexical_cast<std::string>(x);
x = boost::lexical_cast<double>(str);
**[[boost::format:http://boost.cppll.jp/HEAD/libs/format/...
#include<boost/format.hpp>
cout << boost::format("i : %1% - x=%2%, str=%3%") % 1 % ...
boost::format frmt("i : %1% - x=%2%, str=%3%");
frmt % 1;
frmt % 15.0;
frmt % "rml";
std::string str;
str = frmt.str();
str = boost::io::str(frmt);
frmt % 2;
frmt % 20.0;
frmt % "rml2";
cout << boost::format("%2%, %1%, %3%, %1%") % 1 % 2 % 3;
cout << boost::format("%d, %s, %3.1f") % 1 % "2" % 3.0;
**[[boost::function:http://boost.cppll.jp/HEAD/doc/html/f...
#include<boost/function.hpp>
class FuncClass
{
public:
FuncClass(int i, int j) : a(i), b(j) {}
double Dot(int x, int y){ return sqrt((double)(a*x+b*...
int a, b;
};
struct FuncObject
{
double operator()(int x, int y){ return sqrt((double)...
};
double Func(int x, int y)
{
return sqrt((double)(x*x+y*y));
}
boost::function<double (int, int)> length = &Func;
cout << boost::format("length = %f\n") % length(1, 2);
length = FuncObject();
cout << boost::format("length = %f\n") % length(2, 3);
FuncClass obj(3, 4);
length = boost::bind(&FuncClass::Dot, boost::ref(obj), ...
cout << boost::format("length = %f\n") % length(3, 4);
**[[boost::xpressive:http://www.boost.org/doc/libs/1_46_1...
#include <boost/xpressive/xpressive.hpp>
#code(C){{
/*!
*/
static bool Match(const string &str, const string ®_str)
{
using namespace boost::xpressive;
sregex reg = sregex::compile(reg_str);
smatch m;
if(regex_search(str, m, reg)){
return (m.str() == str);
}
else{
return false;
}
}
/*!
*/
static bool Match2(const string &str, const string ®_s...
{
using namespace boost::xpressive;
sregex reg = sregex::compile(reg_str);
smatch m;
if(regex_search(str, m, reg)){
mch.resize(m.size());
for(int i = 0; i < (int)mch.size(); ++i){
mch[i] = m[i];
}
return (m.str() == str);
}
else{
return false;
}
}
}}
**[[boost::random:http://www.boost.org/doc/libs/1_46_1/do...
#include <boost/random.hpp>
#code(C){{
typedef boost::variate_generator< boost::mt19937, boost::...
typedef boost::variate_generator< boost::mt19937, boost::...
/*!
*/
inline rxRandMtGen GenRandomGenerator(const double &_min,...
{
boost::mt19937 gen0(static_cast<unsigned long>(time(0)));
//boost::uniform_real<> dst0(_min, _max);
boost::normal_distribution<> dst0(0, 0.01);
rxRandMtGen rand0(gen0, dst0);
return rand0;
}
/*!
*/
inline rxRandMtUni GenRandomGeneratorMtUni(const double &...
{
boost::mt19937 gen0(static_cast<unsigned long>(time(0)));
boost::uniform_real<> dst0(_min, _max);
rxRandMtUni rand0(gen0, dst0);
return rand0;
}
}}
rxRandMtGen rand = GenRandomGenerator(0.0, 1.0);
for(int i = 0; i < 100; ++i){
cout << rand() << endl;
}
**[[boost::iostreams:http://www.boost.org/doc/libs/1_46_1...
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/operations.hpp>
#code(C){{
class rxCout : public boost::iostreams::sink
{
string m_strLog;
public:
rxCout(string fn)
{
m_strLog = fn;
}
std::streamsize write(const char* s, std::streamsize n)
{
string str;//=s;
str.resize(n);
for(int i = 0; i < n; ++i){
str[i] = s[i];
}
cout << str;
boost::algorithm::replace_all(str, "\n", "");
static std::ofstream fsOut(m_strLog, std::ios::out);
fsOut << str << endl;
return n;
}
};
static boost::iostreams::stream<rxCout> RXCOUT("test.log");
//#define RXCOUT std::cout
class rxCoutFile : public boost::iostreams::sink
{
//std::ofstream m_fsOut0;
public:
rxCoutFile(bool enable)
{
//m_fsOut.open("log/sph.log", std::ios::out);
}
std::streamsize write(const char* s, std::streamsize n)
{
string str;//=s;
str.resize(n);
for(int i = 0; i < n; ++i){
str[i] = s[i];
}
boost::algorithm::replace_all(str, "\n", "");
static std::ofstream fsOut("log/sph.log", std::ios::out);
fsOut << str << endl;
return n;
}
};
static boost::iostreams::stream<rxCoutFile> RXFOUT(true);
}}
**boost::filesystem [#rc01b152]
--[[has_stem():http://www.boost.org/doc/libs/1_48_0/libs/...
--[[has_extension():http://www.boost.org/doc/libs/1_48_0/...
--[[is_absolute():http://www.boost.org/doc/libs/1_48_0/li...
--[[is_relative():http://www.boost.org/doc/libs/1_48_0/li...
--[[make_preferred():http://www.boost.org/doc/libs/1_48_0...
--[[absolute():http://www.boost.org/doc/libs/1_48_0/libs/...
--[[create_symlink():http://www.boost.org/doc/libs/1_48_0...
--[[read_symlink():http://www.boost.org/doc/libs/1_48_0/l...
--[[resize_file():http://www.boost.org/doc/libs/1_48_0/li...
--[[unique_path():http://www.boost.org/doc/libs/1_48_0/li...
#include(build_boost,notitle)
-[[Boost C++ Libraries:http://boost.cppll.jp/HEAD/]]
-[[Let's Boost:http://www.kmonos.net/alang/boost/]]
終了行:
-----
#contents
-----
**[[boost::bind:http://boost.cppll.jp/HEAD/libs/bind/bind...
#include <boost/bind.hpp>
#code(C){{
int func2(int x, int y)
{
return x+y;
}
int func3(int x, int y, int z)
{
return x+y+z;
}
void main(void)
{
boost::function<int (int, int)> func;
func = func2;
cout << func(1, 2) << endl;
func = boost::bind(func3, _1, _2, 0);
cout << func(1, 2) << endl;
}
}}
#code(C){{
Class1 *obj = new Class1;
boost::function<int (int)> func = boost::bind(&Class1::Fu...
}}
**[[boost::mem_fn:http://boost.cppll.jp/HEAD/libs/bind/me...
#include<boost/mem_fn.hpp>
class MemClass
{
public:
MemClass(int x) : a(x){}
void Print(){ cout << a << endl; }
private:
int a;
};
void main(void)
{
vector<MemClass> v;
v.push_back(MemClass(1));
v.push_back(MemClass(2));
v.push_back(MemClass(3));
for_each(v.begin(), v.end(), boost::mem_fn(&MemClass:...
}
**[[boost::lexical_cast:http://boost.cppll.jp/HEAD/libs/c...
#include<boost/lexical_cast.hpp>
double x = 0.0;
std::string str;
str = boost::lexical_cast<std::string>(x);
x = boost::lexical_cast<double>(str);
**[[boost::format:http://boost.cppll.jp/HEAD/libs/format/...
#include<boost/format.hpp>
cout << boost::format("i : %1% - x=%2%, str=%3%") % 1 % ...
boost::format frmt("i : %1% - x=%2%, str=%3%");
frmt % 1;
frmt % 15.0;
frmt % "rml";
std::string str;
str = frmt.str();
str = boost::io::str(frmt);
frmt % 2;
frmt % 20.0;
frmt % "rml2";
cout << boost::format("%2%, %1%, %3%, %1%") % 1 % 2 % 3;
cout << boost::format("%d, %s, %3.1f") % 1 % "2" % 3.0;
**[[boost::function:http://boost.cppll.jp/HEAD/doc/html/f...
#include<boost/function.hpp>
class FuncClass
{
public:
FuncClass(int i, int j) : a(i), b(j) {}
double Dot(int x, int y){ return sqrt((double)(a*x+b*...
int a, b;
};
struct FuncObject
{
double operator()(int x, int y){ return sqrt((double)...
};
double Func(int x, int y)
{
return sqrt((double)(x*x+y*y));
}
boost::function<double (int, int)> length = &Func;
cout << boost::format("length = %f\n") % length(1, 2);
length = FuncObject();
cout << boost::format("length = %f\n") % length(2, 3);
FuncClass obj(3, 4);
length = boost::bind(&FuncClass::Dot, boost::ref(obj), ...
cout << boost::format("length = %f\n") % length(3, 4);
**[[boost::xpressive:http://www.boost.org/doc/libs/1_46_1...
#include <boost/xpressive/xpressive.hpp>
#code(C){{
/*!
*/
static bool Match(const string &str, const string ®_str)
{
using namespace boost::xpressive;
sregex reg = sregex::compile(reg_str);
smatch m;
if(regex_search(str, m, reg)){
return (m.str() == str);
}
else{
return false;
}
}
/*!
*/
static bool Match2(const string &str, const string ®_s...
{
using namespace boost::xpressive;
sregex reg = sregex::compile(reg_str);
smatch m;
if(regex_search(str, m, reg)){
mch.resize(m.size());
for(int i = 0; i < (int)mch.size(); ++i){
mch[i] = m[i];
}
return (m.str() == str);
}
else{
return false;
}
}
}}
**[[boost::random:http://www.boost.org/doc/libs/1_46_1/do...
#include <boost/random.hpp>
#code(C){{
typedef boost::variate_generator< boost::mt19937, boost::...
typedef boost::variate_generator< boost::mt19937, boost::...
/*!
*/
inline rxRandMtGen GenRandomGenerator(const double &_min,...
{
boost::mt19937 gen0(static_cast<unsigned long>(time(0)));
//boost::uniform_real<> dst0(_min, _max);
boost::normal_distribution<> dst0(0, 0.01);
rxRandMtGen rand0(gen0, dst0);
return rand0;
}
/*!
*/
inline rxRandMtUni GenRandomGeneratorMtUni(const double &...
{
boost::mt19937 gen0(static_cast<unsigned long>(time(0)));
boost::uniform_real<> dst0(_min, _max);
rxRandMtUni rand0(gen0, dst0);
return rand0;
}
}}
rxRandMtGen rand = GenRandomGenerator(0.0, 1.0);
for(int i = 0; i < 100; ++i){
cout << rand() << endl;
}
**[[boost::iostreams:http://www.boost.org/doc/libs/1_46_1...
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/operations.hpp>
#code(C){{
class rxCout : public boost::iostreams::sink
{
string m_strLog;
public:
rxCout(string fn)
{
m_strLog = fn;
}
std::streamsize write(const char* s, std::streamsize n)
{
string str;//=s;
str.resize(n);
for(int i = 0; i < n; ++i){
str[i] = s[i];
}
cout << str;
boost::algorithm::replace_all(str, "\n", "");
static std::ofstream fsOut(m_strLog, std::ios::out);
fsOut << str << endl;
return n;
}
};
static boost::iostreams::stream<rxCout> RXCOUT("test.log");
//#define RXCOUT std::cout
class rxCoutFile : public boost::iostreams::sink
{
//std::ofstream m_fsOut0;
public:
rxCoutFile(bool enable)
{
//m_fsOut.open("log/sph.log", std::ios::out);
}
std::streamsize write(const char* s, std::streamsize n)
{
string str;//=s;
str.resize(n);
for(int i = 0; i < n; ++i){
str[i] = s[i];
}
boost::algorithm::replace_all(str, "\n", "");
static std::ofstream fsOut("log/sph.log", std::ios::out);
fsOut << str << endl;
return n;
}
};
static boost::iostreams::stream<rxCoutFile> RXFOUT(true);
}}
**boost::filesystem [#rc01b152]
--[[has_stem():http://www.boost.org/doc/libs/1_48_0/libs/...
--[[has_extension():http://www.boost.org/doc/libs/1_48_0/...
--[[is_absolute():http://www.boost.org/doc/libs/1_48_0/li...
--[[is_relative():http://www.boost.org/doc/libs/1_48_0/li...
--[[make_preferred():http://www.boost.org/doc/libs/1_48_0...
--[[absolute():http://www.boost.org/doc/libs/1_48_0/libs/...
--[[create_symlink():http://www.boost.org/doc/libs/1_48_0...
--[[read_symlink():http://www.boost.org/doc/libs/1_48_0/l...
--[[resize_file():http://www.boost.org/doc/libs/1_48_0/li...
--[[unique_path():http://www.boost.org/doc/libs/1_48_0/li...
#include(build_boost,notitle)
-[[Boost C++ Libraries:http://boost.cppll.jp/HEAD/]]
-[[Let's Boost:http://www.kmonos.net/alang/boost/]]
ページ名: