9 Ağustos 2017 Çarşamba

graph edges metodu

Giriş
Tüm edgeleri dolaşmamızı sağlayan bir iterator çifti döner. Bu metod ile vertices metodu kardeştir.

edges - graph
Bu metod iki tane iterator döner.
Örnek
Şöyle yaparız.
std::pair<Graph::edge_iterator, Graph::edge_iterator> es = boost::edges(g);
Tanımlama zor geliyorsa şöyle yaparız.
auto es = boost::edges(g);
Örnek
Elimizde şöyle bir grap olsun
struct Vertex { int id; double data; };
struct Edge { float distance; };

typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS,
  Vertex, Edge> Graph;
Edge'leri dolaşmak için şöyle yaparız.
// Iterate through the edges and print them out
auto es = boost::edges(g);
for (auto eit = es.first; eit != es.second; ++eit) {
  std::cout << boost::source(*eit, g) << ' ' << boost::target(*eit, g);
}
Çıktı olarak şunu alırız
0 0
1 2
1 4
1 3
2 4

function

Giriş
Şu satırı dahil ederiz.
#include <boost/function.hpp>
Tanımlama
Şöyle yaparız.
using function_t = boost::function3< void, int, int, int >;

8 Ağustos 2017 Salı

regex regex Sınıfı

Giriş
Şu satırı dahil ederiz.
#include <boost/regex.hpp>
Constructor
Şöyle yaparız.
boost::regex r ("...");
Şöyle yaparız.

boost::regex r {"..."};
Copy Constructor
Şöyle yaparız.
std::string pattern = "...";
boost::regex re = boost::regex (pattern);
Perl
Şöyle yaparız.
//a case insensitive Perl regular expression:
boost::regex e2(pattern, boost::regex::perl|boost::regex::icase);

7 Ağustos 2017 Pazartesi

multiprecision number Sınıfı

Giriş
Şu satırı dahil ederiz.
#include <boost/multiprecision/gmp.hpp> 
List of arbitrary-precision arithmetic software sayfasına bakılabilir. Bu sınıf aslında direkt kullanılmaz. Genellikle bir typedef ile kullanılır. cpp_int sınıfına bakılabilir.

Tanımlama - backend type
Şöyle yaparız. Altta GNU MP BigNum kütüphanesini kullanır.
typedef mp::number<mp::gmp_float<4>> float_type;
Şöyle yaparız.
const int precision = 100;
typedef mp::number<mp::cpp_dec_float<100> > float_type;
Tanımlama - backend type + expression template
Açıklama şöyle
You can have all the tail-call implementation details as you expect it by opting out of the lazy-evaluation template expressions (boost::multiprecision::et_off as described in the links), but be sure to check that the reduced code-size and perceived TCO optimization actually leads to increased performance.
Şöyle yaparız.
using big_int = bmp::number<bmp::cpp_int::backend_type, bmp::et_off>;
Constructor - string
Precision olarak 100 verdiysek noktadan sonra 100 rakam verebiliriz. Şöyle yaparız.
float_type pi(
    "3.1415926535"
      "8979323846"
      "2643383279"
      "5028841971"
      "6939937510"
      "5820974944"
      "5923078164"
      "0628620899"
      "8628034825"
      "3421170679"
  );
Copy Constructor
Şöyle yaparız.
float_type x2 = x (...);
convert_to metodu
double'a çevirmek için şöyle yaparız.
float_type v = ...;
double value = v.convert_to<double>();
std:string'e çevirmek için şöyle yaparız.
std::string str = v.convert_to<std::string>();
mpz_int'e çevirmek için şöyle yaparız.
typedef mp::mpz_int mpint;
typedef mp::number<mp::gmp_float<4> > mpfloat;


mpfloat p = ...;
std::cout << p.template convert_to<mpint>() << std::endl;
operator * metodu
Şöyle yaparız.
x = (x * x);
operator = metodu
Şöyle yaparız.
float_type x = 0.0;
operator << metodu - Bitshift
Şöyle yaparız.
uint128_t number = 100;
uint32_t ten = 10;

auto leftShift = number << ten;
Bu metod sağ tarafa sadece integral sayıları alır. Şu kod derlehttps://stackoverflow.com/questions/45529016/bitwise-operation-using-c-boost-librarynmez.
cpp_int ten = 10
cout << (number<<c) << endl;
operator || metodu
Şöyle yaparız.
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

int128_t int64left = CreateRandomInt64ViaBoost()
int128_t int64right = CreateRandomInt64ViaBoost()

int128_t randomInt = int64left << 64 | int64right;



2 Ağustos 2017 Çarşamba

locale generator Sınıfı

Giriş
Şu satırı dahil ederiz.
#include <boost/locale.hpp>
Constructor
Şöyle yaparız.
boost::locale::generator gen;
add_messages_domain metodu
Şöyle yaparız.
gen.add_messages_domain("messages");
add_messages_path metodu
Şöyle yaparız.
gen.add_messages_path("...");
locale_cache_enabled metodu
Şöyle yaparız.
gen.locale_cache_enabled(true);
generate metodu
Şöyle yaparız.
boost::locale::generator gen;
auto CN = gen.generate("zh_CN.GBK");
operator () metodu
std::locale nesnesi döner. İşletim sisteminin varsayılan locale'ini yaratmak için şöyle yaparız.
std::locale loc = gen("");
İsmi belirtilen locale nesnesini yaratmak için  şöyle yaparız.
std::locale loc = gen("ISO8859-15");
İsmi belirtilen locale nesnesini yaratmak için şöyle yaparız.
std::locale loc = gen ("en_US.UTF-8");
Diğer
Yaratılan locale nesnesini tüm uygulamada kullanmak için şöyle yaparız
std::locale::global (loc);
Eğer sadece bir stream içinde kullanacaksak şöyle yaparız.
cout.imbue (loc);