text:
#pragma once

#include <paper/lib/numbers.hpp>

#include <assert.h>
#include <blake2/blake2.h>
#include <boost/property_tree/json_parser.hpp>
#include <streambuf>

namespace paper
{
std::string to_string_hex (uint64_t);
bool from_string_hex (std::string const &, uint64_t &);
// We operate on streams of uint8_t by convention
using stream = std::basic_streambuf<uint8_t>;
// Read a raw byte stream the size of `T' and fill value.
template <typename T>
bool read (paper::stream & stream_a, T & value)
{
	static_assert (std::is_pod<T>::value, "Can't stream read non-standard layout types");
	auto amount_read (stream_a.sgetn (reinterpret_cast<uint8_t *> (&value), sizeof (value)));
	return amount_read != sizeof (value);
}
template <typename T>
void write (paper::stream & stream_a, T const & value)
{
	static_assert (std::is_pod<T>::value, "Can't stream write non-standard layout types");
	auto amount_written (stream_a.sputn (reinterpret_cast<uint8_t const *> (&value), sizeof (value)));
	assert (amount_written == sizeof (value));
}
class block_visitor;
enum class block_type : uint8_t
{
	invalid,
	not_a_block,
	send,
	receive,
	open,
	change
};
class block
{
public:
	// Return a digest of the hashables in this block.
	paper::block_hash hash () const;
	std::string to_json ();
	virtual void hash (blake2b_state &) const = 0;
	virtual uint64_t block_work () const = 0;
	virtual void block_work_set (uint64_t) = 0;
	// Previous block in account's chain, zero for open block
	virtual paper::block_hash previous () const = 0;
	// Source block for open/receive blocks, zero otherwise.
	virtual paper::block_hash source () const = 0;
	// Previous block or account number for open blocks
	virtual paper::block_hash root () const = 0;
	virtual paper::account representative () const = 0;
	virtual void serialize (paper::stream &) const = 0;
	virtual void serialize_json (std::string &) const = 0;
	virtual void visit (paper::block_visitor &) const = 0;
	virtual bool operator== (paper::block const &) const = 0;
	virtual paper::block_type type () const = 0;
	virtual paper::signature block_signature () const = 0;
	virtual void signature_set (paper::uint512_union const &) = 0;
	virtual ~block () = default;
};
class send_hashables
{
public:
	send_hashables (paper::account const &, paper::block_hash const &, paper::amount const &);
	send_hashables (bool &, paper::stream &);
	send_hashables (bool &, boost::property_tree::ptree const &);
	void hash (blake2b_state &) const;
	paper::block_hash previous;
	paper::account destination;
	paper::amount balance;
};
class send_block : public paper::block
{
public:
	send_block (paper::block_hash const &, paper::account const &, paper::amount const &, paper::raw_key const &, paper::public_key const &, uint64_t);
	send_block (bool &, paper::stream &);
	send_block (bool &, boost::property_tree::ptree const &);
	virtual ~send_block () = default;
	using paper::block::hash;
	void hash (blake2b_state &) const override;
	uint64_t block_work () const override;
	void block_work_set (uint64_t) override;
	paper::block_hash previous () const override;
	paper::block_hash source () const override;
	paper::block_hash root () const override;
	paper::account representative () const override;
	void serialize (paper::stream &) const override;
	void serialize_json (std::string &) const override;
	bool deserialize (paper::stream &);
	bool deserialize_json (boost::property_tree::ptree const &);
	void visit (paper::block_visitor &) const override;
	paper::block_type type () const override;
	paper::signature block_signature () const override;
	void signature_set (paper::uint512_union const &) override;
	bool operator== (paper::block const &) const override;
	bool operator== (paper::send_block const &) const;
	static size_t constexpr size = sizeof (paper::account) + sizeof (paper::block_hash) + sizeof (paper::amount) + sizeof (paper::signature) + sizeof (uint64_t);
	send_hashables hashables;
	paper::signature signature;
	uint64_t work;
};
class receive_hashables
{
public:
	receive_hashables (paper::block_hash const &, paper::block_hash const &);
	receive_hashables (bool &, paper::stream &);
	receive_hashables (bool &, boost::property_tree::ptree const &);
	void hash (blake2b_state &) const;
	paper::block_hash previous;
	paper::block_hash source;
};
class receive_block : public paper::block
{
public:
	receive_block (paper::block_hash const &, paper::block_hash const &, paper::raw_key const &, paper::public_key const &, uint64_t);
	receive_block (bool &, paper::stream &);
	receive_block (bool &, boost::property_tree::ptree const &);
	virtual ~receive_block () = default;
	using paper::block::hash;
	void hash (blake2b_state &) const override;
	uint64_t block_work () const override;
	void block_work_set (uint64_t) override;
	paper::block_hash previous () const override;
	paper::block_hash source () const override;
	paper::block_hash root () const override;
	paper::account representative () const override;
	void serialize (paper::stream &) const override;
	void serialize_json (std::string &) const override;
	bool deserialize (paper::stream &);
	bool deserialize_json (boost::property_tree::ptree const &);
	void visit (paper::block_visitor &) const override;
	paper::block_type type () const override;
	paper::signature block_signature () const override;
	void signature_set (paper::uint512_union const &) override;
	bool operator== (paper::block const &) const override;
	bool operator== (paper::receive_block const &) const;
	static size_t constexpr size = sizeof (paper::block_hash) + sizeof (paper::block_hash) + sizeof (paper::signature) + sizeof (uint64_t);
	receive_hashables hashables;
	paper::signature signature;
	uint64_t work;
};
class open_hashables
{
public:
	open_hashables (paper::block_hash const &, paper::account const &, paper::account const &);
	open_hashables (bool &, paper::stream &);
	open_hashables (bool &, boost::property_tree::ptree const &);
	void hash (blake2b_state &) const;
	paper::block_hash source;
	paper::account representative;
	paper::account account;
};
class open_block : public paper::block
{
public:
	open_block (paper::block_hash const &, paper::account const &, paper::account const &, paper::raw_key const &, paper::public_key const &, uint64_t);
	open_block (paper::block_hash const &, paper::account const &, paper::account const &, std::nullptr_t);
	open_block (bool &, paper::stream &);
	open_block (bool &, boost::property_tree::ptree const &);
	virtual ~open_block () = default;
	using paper::block::hash;
	void hash (blake2b_state &) const override;
	uint64_t block_work () const override;
	void block_work_set (uint64_t) override;
	paper::block_hash previous () const override;
	paper::block_hash source () const override;
	paper::block_hash root () const override;
	paper::account representative () const override;
	void serialize (paper::stream &) const override;
	void serialize_json (std::string &) const override;
	bool deserialize (paper::stream &);
	bool deserialize_json (boost::property_tree::ptree const &);
	void visit (paper::block_visitor &) const override;
	paper::block_type type () const override;
	paper::signature block_signature () const override;
	void signature_set (paper::uint512_union const &) override;
	bool operator== (paper::block const &) const override;
	bool operator== (paper::open_block const &) const;
	static size_t constexpr size = sizeof (paper::block_hash) + sizeof (paper::account) + sizeof (paper::account) + sizeof (paper::signature) + sizeof (uint64_t);
	paper::open_hashables hashables;
	paper::signature signature;
	uint64_t work;
};
class change_hashables
{
public:
	change_hashables (paper::block_hash const &, paper::account const &);
	change_hashables (bool &, paper::stream &);
	change_hashables (bool &, boost::property_tree::ptree const &);
	void hash (blake2b_state &) const;
	paper::block_hash previous;
	paper::account representative;
};
class change_block : public paper::block
{
public:
	change_block (paper::block_hash const &, paper::account const &, paper::raw_key const &, paper::public_key const &, uint64_t);
	change_block (bool &, paper::stream &);
	change_block (bool &, boost::property_tree::ptree const &);
	virtual ~change_block () = default;
	using paper::block::hash;
	void hash (blake2b_state &) const override;
	uint64_t block_work () const override;
	void block_work_set (uint64_t) override;
	paper::block_hash previous () const override;
	paper::block_hash source () const override;
	paper::block_hash root () const override;
	paper::account representative () const override;
	void serialize (paper::stream &) const override;
	void serialize_json (std::string &) const override;
	bool deserialize (paper::stream &);
	bool deserialize_json (boost::property_tree::ptree const &);
	void visit (paper::block_visitor &) const override;
	paper::block_type type () const override;
	paper::signature block_signature () const override;
	void signature_set (paper::uint512_union const &) override;
	bool operator== (paper::block const &) const override;
	bool operator== (paper::change_block const &) const;
	static size_t constexpr size = sizeof (paper::block_hash) + sizeof (paper::account) + sizeof (paper::signature) + sizeof (uint64_t);
	paper::change_hashables hashables;
	paper::signature signature;
	uint64_t work;
};
class block_visitor
{
public:
	virtual void send_block (paper::send_block const &) = 0;
	virtual void receive_block (paper::receive_block const &) = 0;
	virtual void open_block (paper::open_block const &) = 0;
	virtual void change_block (paper::change_block const &) = 0;
	virtual ~block_visitor () = default;
};
std::unique_ptr<paper::block> deserialize_block (paper::stream &);
std::unique_ptr<paper::block> deserialize_block (paper::stream &, paper::block_type);
std::unique_ptr<paper::block> deserialize_block_json (boost::property_tree::ptree const &);
void serialize_block (paper::stream &, paper::block const &);
}

max_stars_repo_name: williamstarkro/paper

max_issues_repo_name: williamstarkro/paper

max_forks_repo_name: williamstarkro/paper


text: #include <boost/python/object/inheritance.hpp>

ext: hpp

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
#pragma comment(linker, "/STACK:100000000")
#pragma comment(linker, "/HEAP:1000000000")

#include <iostream>
#include <fstream>
#include <Eigen/Dense>
#include "Lookup.h"
#include <random>
#include <string>
#include <algorithm>
#include <thread>
#include <iterator>
using std::string;
using Eigen::MatrixXd;
using Eigen::VectorXd;
#include <chrono>

float Q_rsqrt(float number)
{
	long i;
	float x2, y;
	const float threehalfs = 1.5F;

	x2 = number * 0.5F;
	y = number;
	i = *(long *)&y;                       // evil floating point bit level hacking
	i = 0x5f3759df - (i >> 1);               // what the fuck?
	y = *(float *)&i;
	y = y * (threehalfs - (x2 * y * y));   // 1st iteration
										   //	y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed

	return y;
}

void call_from_thread() {
	std::cout << "Hello, World" << std::endl;

}
float get_random(float min, float max)
{
	static std::mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());
	std::uniform_real_distribution<> dis(min, max);
	return dis(rng);
}

string GetInput(string message) {
	printf(message.c_str());
	string response;
	std::getline(std::cin, response);

	return response;
}

void Write(string filename, string value) {
	std::ofstream file;
	file.open(filename);
	file << value.c_str();
	file.close();
}

string Read(string filename) {
	{
		string line;
		std::ifstream input(filename);
		if (input.is_open())
		{
			std::stringstream strStream;
			strStream << input.rdbuf();//read the file
			return strStream.str();//str holds the content of the file
		}
		else
		{
			return "";
		}
	}
}

void MakeLower(string& value) {
	std::transform(value.begin(), value.end(), value.begin(), ::tolower);
}

int main()
{
	auto inputFile = GetInput("Please enter full filename to train chain from : \n");
	auto outputFile = GetInput("Please enter full filename set output to : \n");

	auto defaults = split(Read("default.ini"), v<string>("\n"));
	bool usedDefaults = false;

	if (inputFile == "") {
		inputFile = defaults[0];
		bool usedDefaults = true;
	}
	if (outputFile == "") {
		outputFile = defaults[1];
		bool usedDefaults = true;
	}

	if (!usedDefaults)
		Write("default.ini", inputFile + "\n" + outputFile);

	string trainingText = "";

	{
		string line;
		std::ifstream input(inputFile);
		if (input.is_open())
		{
			std::stringstream strStream;
			strStream << input.rdbuf();//read the file
			trainingText = strStream.str();//str holds the content of the file
		}
		else {
			return 0;
		}
	}
	auto words = split(trainingText, v<string>(" ", "	 ", ".", ",", "(", ")", ";", "\"", "-", "!", ":", "?"));

	MatrixXd m(2, 2);
	m(0, 0) = 3;
	m(1, 0) = 2.;
	m(0, 1) = -1;
	m(1, 1) = m(1, 0) + m(0, 1);
	std::cout << m << std::endl;
	Lookup lookup;
	auto result = lookup.Convert(words);
	auto resultSize = (int)result.size();
	auto lookupSize = (int)lookup.size();

	MatrixXd data = MatrixXd::Zero(lookupSize, lookupSize);

	for (int index = 0; index < resultSize; index++) {
		for (int subIndex = std::max(0, index - 5); subIndex < std::min(resultSize, index + 30); subIndex++) {
			double weight = 5;
			if (subIndex < index)
				weight = 0.2;
			else if (subIndex == index)
				continue;

			//auto change = weight / pow(index - subIndex, 2);
			data(result[subIndex], result[index]) += weight / pow(abs(index - subIndex), 1.2);
		//	data(result[subIndex], result[index]) = std::max(0.0, data(result[subIndex], result[index]));
		}
	}

	for (int index = 0; index < data.cols(); index++) {
		data.col(index) /= data.col(index).sum();
	}

	VectorXd input = VectorXd::Zero(lookupSize);
	input[0] = 1;

	vector<int> textOutput(500);

	string finalResult = "";
	for (int i = 0; i < 500; i++) {
		input = data * input;
		//auto max = input[0];
		//max = input[0];
		//auto maxIndex = 0;

		//for (int index = 1; index < lookupSize; index++) {
		//	maxIndex = input[index] > max ? index : maxIndex;

		//	if (maxIndex == index) {
		//		max = input[index];
		//	}
		//}

		float potSize = (float)input.sum();
		auto random = (double)get_random(0, potSize);

		int index = 0;
		for (double cursor = 0; cursor + input[index] < random; cursor += input[index]) {
			index++;
		}

		input[index] = 1;

		textOutput[i] = index;
		finalResult = join(lookup.Extract<string>(textOutput, ""), " ");
		std::cout << finalResult + "\n";
	}

	Write(outputFile, finalResult);

	int i = 0;
}

ext: cpp

max_stars_repo_name: nathanwblair/markov

max_issues_repo_name: nathanwblair/markov

max_forks_repo_name: nathanwblair/markov


text:
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.

// Use, modification and distribution is subject to 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)

#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_BACKTRACK_CHECK_SI_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_BACKTRACK_CHECK_SI_HPP

#include <cstddef>

#include <string>

#include <boost/range.hpp>

#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
#include <boost/geometry/core/access.hpp>

#  include <boost/geometry/algorithms/detail/has_self_intersections.hpp>

#if defined(BOOST_GEOMETRY_DEBUG_INTERSECTION) || defined(BOOST_GEOMETRY_OVERLAY_REPORT_WKT)
#  include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
#  include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
#endif

namespace boost { namespace geometry
{

#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace overlay
{

template <typename Turns>
inline void clear_visit_info(Turns& turns)
{
    typedef typename boost::range_value<Turns>::type tp_type;

    for (typename boost::range_iterator<Turns>::type
        it = boost::begin(turns);
        it != boost::end(turns);
        ++it)
    {
        for (typename boost::range_iterator
            <
                typename tp_type::container_type
            >::type op_it = boost::begin(it->operations);
            op_it != boost::end(it->operations);
            ++op_it)
        {
            op_it->visited.clear();
        }
        it->discarded = false;
    }
}

struct backtrack_state
{
    bool m_good;

    inline backtrack_state() : m_good(true) {}
    inline void reset() { m_good = true; }
    inline bool good() const { return m_good; }
};

template
<
    typename Geometry1,
    typename Geometry2
>
class backtrack_check_self_intersections
{
    struct state : public backtrack_state
    {
        bool m_checked;
        inline state()
            : m_checked()
        {}
    };
public :
    typedef state state_type;

    template <typename Operation, typename Rings, typename Turns>
    static inline void apply(std::size_t size_at_start,
                Rings& rings, typename boost::range_value<Rings>::type& ring,
                Turns& turns, Operation& operation,
                std::string const& ,
                Geometry1 const& geometry1,
                Geometry2 const& geometry2,
                state_type& state
                )
    {
        state.m_good = false;

        // Check self-intersections and throw exception if appropriate
        if (! state.m_checked)
        {
            state.m_checked = true;
            has_self_intersections(geometry1);
            has_self_intersections(geometry2);
        }

        // Make bad output clean
        rings.resize(size_at_start);
        ring.clear();

        // Reject this as a starting point
        operation.visited.set_rejected();

        // And clear all visit info
        clear_visit_info(turns);
    }
};

#ifdef BOOST_GEOMETRY_OVERLAY_REPORT_WKT
template
<
    typename Geometry1,
    typename Geometry2
>
class backtrack_debug
{
public :
    typedef backtrack_state state_type;

    template <typename Operation, typename Rings, typename Turns>
    static inline void apply(std::size_t size_at_start,
                Rings& rings, typename boost::range_value<Rings>::type& ring,
                Turns& turns, Operation& operation,
                std::string const& reason,
                Geometry1 const& geometry1,
                Geometry2 const& geometry2,
                state_type& state
                )
    {
        std::cout << " REJECT " << reason << std::endl;

        state.m_good = false;

        rings.resize(size_at_start);
        ring.clear();
        operation.visited.set_rejected();
        clear_visit_info(turns);

        int c = 0;
        for (int i = 0; i < turns.size(); i++)
        {
            for (int j = 0; j < 2; j++)
            {
                if (turns[i].operations[j].visited.rejected())
                {
                    c++;
                }
            }
        }
        std::cout << "BACKTRACK (" << reason << " )"
            << " " << c << " of " << turns.size() << " rejected"
            << std::endl;
        std::cout
            << geometry::wkt(geometry1) << std::endl
            << geometry::wkt(geometry2) << std::endl;
    }
};
#endif // BOOST_GEOMETRY_OVERLAY_REPORT_WKT

}} // namespace detail::overlay
#endif // DOXYGEN_NO_DETAIL

}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_BACKTRACK_CHECK_SI_HPP


text:
#include "stdafx.h"
#include "EditTransRecordDialogModal.h"

#include <boost/test/unit_test.hpp>
#ifdef UNIT_TEST
BOOST_AUTO_TEST_SUITE( TestCEditTransRecordDialogModal )

	BOOST_AUTO_TEST_CASE( instantiate)
	{
		CEditTransRecordDialogModal dialog ;
		BOOST_CHECK_EQUAL(IDD_EDIT_RECORD, CEditTransRecordDialogModal::IDD) ;
	}
	BOOST_AUTO_TEST_CASE( is_gloss_mem)
	{
		CEditTransRecordDialogModal dialog ;
		BOOST_CHECK(! dialog.m_is_glossary) ;
	}

	// CEditTransRecordDialogModal message processing

BOOST_AUTO_TEST_SUITE_END()
#endif

max_stars_repo_name: ultimatezen/felix

max_issues_repo_name: ultimatezen/felix

max_forks_repo_name: ultimatezen/felix


text:
// Copyright (C) 2015-2016 Andrzej Krzemienski.
//
// Use, modification, and distribution is subject to 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/optional for documentation.
//
// You are welcome to contact the author at:
//  akrzemi1@gmail.com

#ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_REFERENCE_SPEC_AJK_03OCT2015_HPP
#define BOOST_OPTIONAL_DETAIL_OPTIONAL_REFERENCE_SPEC_AJK_03OCT2015_HPP

#ifdef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_const.hpp>
#endif

# if 1

namespace boost {

namespace detail {

#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES

template <class From>
void prevent_binding_rvalue()
{
#ifndef BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES
    BOOST_STATIC_ASSERT_MSG(boost::is_lvalue_reference<From>::value,
                            "binding rvalue references to optional lvalue references is disallowed");
#endif
}

template <class T>
BOOST_DEDUCED_TYPENAME boost::remove_reference<T>::type& forward_reference(T&& r)
{
    BOOST_STATIC_ASSERT_MSG(boost::is_lvalue_reference<T>::value,
                            "binding rvalue references to optional lvalue references is disallowed");
    return boost::forward<T>(r);
}

#endif // BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES

template <class From>
void prevent_assignment_from_false_const_integral()
{
#ifndef BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES
#ifdef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
    // MSVC compiler without rvalue refernces: we need to disable the asignment from
    // const integral lvalue reference, as it may be an invalid temporary
    BOOST_STATIC_ASSERT_MSG(!(boost::is_const<From>::value && boost::is_integral<From>::value),
                            "binding const lvalue references to integral types is disabled in this compiler");
#endif
#endif
}

template <class T>
struct is_optional_
{
  static const bool value = false;
};

template <class U>
struct is_optional_< ::boost::optional<U> >
{
  static const bool value = true;
};

template <class T>
struct is_no_optional
{
  static const bool value = !is_optional_<BOOST_DEDUCED_TYPENAME boost::decay<T>::type>::value;
};

} // namespace detail

template <class T>
class optional<T&> : public optional_detail::optional_tag
{
    T* ptr_;

public:
    typedef T& value_type;
    typedef T& reference_type;
    typedef T& reference_const_type;
    typedef T& rval_reference_type;
    typedef T* pointer_type;
    typedef T* pointer_const_type;

    optional() BOOST_NOEXCEPT : ptr_() {}
    optional(none_t) BOOST_NOEXCEPT : ptr_() {}

    template <class U>
        explicit optional(const optional<U&>& rhs) BOOST_NOEXCEPT : ptr_(rhs.ptr_) {}
    optional(const optional& rhs) BOOST_NOEXCEPT : ptr_(rhs.ptr_) {}

    optional& operator=(const optional& rhs) BOOST_NOEXCEPT { ptr_ = rhs.ptr_; return *this; }
    template <class U>
        optional& operator=(const optional<U&>& rhs) BOOST_NOEXCEPT { ptr_ = rhs.ptr_; return *this; }
    optional& operator=(none_t) BOOST_NOEXCEPT { ptr_ = 0; return *this; }

    void swap(optional& rhs) BOOST_NOEXCEPT { std::swap(ptr_, rhs.ptr_); }
    T& get() const { BOOST_ASSERT(ptr_); return   *ptr_; }

    T* get_ptr() const BOOST_NOEXCEPT { return ptr_; }
    T* operator->() const { BOOST_ASSERT(ptr_); return ptr_; }
    T& operator*() const { BOOST_ASSERT(ptr_); return *ptr_; }
    T& value() const { return ptr_ ? *ptr_ : (throw_exception(bad_optional_access()), *ptr_); }

    bool operator!() const BOOST_NOEXCEPT { return ptr_ == 0; }
    BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()

    void reset() BOOST_NOEXCEPT { ptr_ = 0; }

    bool is_initialized() const BOOST_NOEXCEPT { return ptr_ != 0; }

#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES

    template <class R>
        optional(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
        : ptr_(boost::addressof(r)) { detail::prevent_binding_rvalue<R>(); }

    template <class R>
        optional(bool cond, R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
        : ptr_(cond ? boost::addressof(r) : 0) { detail::prevent_binding_rvalue<R>(); }

    template <class R>
        BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, optional<T&>&>::type
        operator=(R&& r) BOOST_NOEXCEPT { detail::prevent_binding_rvalue<R>(); ptr_ = boost::addressof(r); return *this; }

    template <class R>
        void emplace(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
        { detail::prevent_binding_rvalue<R>(); ptr_ = boost::addressof(r); }

    template <class R>
      T& get_value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) const BOOST_NOEXCEPT
      { detail::prevent_binding_rvalue<R>(); return ptr_ ? *ptr_ : r; }

    template <class R>
        T& value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) const BOOST_NOEXCEPT
        { detail::prevent_binding_rvalue<R>(); return ptr_ ? *ptr_ : r; }

    template <class R>
      void reset(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
      { detail::prevent_binding_rvalue<R>(); ptr_ = boost::addressof(r); }

    template <class F>
        T& value_or_eval(F f) const { return ptr_ ? *ptr_ : detail::forward_reference(f()); }

#else  // BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES

    template <class U>
        optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT : ptr_(boost::addressof(v)) { }

    template <class U>
        optional(bool cond, U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT : ptr_(cond ? boost::addressof(v) : 0) {}

    template <class U>
        BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, optional<T&>&>::type
        operator=(U& v) BOOST_NOEXCEPT
        {
            detail::prevent_assignment_from_false_const_integral<U>();
            ptr_ = boost::addressof(v); return *this;
        }

    template <class U>
        void emplace(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT
        { ptr_ = boost::addressof(v); }

    template <class U>
      T& get_value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) const BOOST_NOEXCEPT
      { return ptr_ ? *ptr_ : v; }

    template <class U>
        T& value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) const BOOST_NOEXCEPT
        { return ptr_ ? *ptr_ : v; }

    template <class U>
      void reset(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT
      { ptr_ = boost::addressof(v); }

    template <class F>
      T& value_or_eval(F f) const { return ptr_ ? *ptr_ : f(); }

#endif // BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
};

template <class T>
  void swap ( optional<T&>& x, optional<T&>& y) BOOST_NOEXCEPT
{
  x.swap(y);
}

} // namespace boost

#endif // 1/0

#endif // header guard


text:
/*
 * Copyright 2011-2013 Esrille Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "HTMLDivElementImp.h"
#include <boost/concept_check.hpp>

#include "one_at_a_time.hpp"

constexpr auto Intern = &one_at_a_time::hash<char16_t>;

#include "css/CSSStyleDeclarationImp.h"

namespace org
{
namespace w3c
{
namespace dom
{
namespace bootstrap
{

css::CSSStyleDeclaration HTMLDivElementImp::getStyle()
{
    if (hasStyle())
        return HTMLElementImp::getStyle();
    css::CSSStyleDeclaration style = HTMLElementImp::getStyle();
    if (auto imp = std::dynamic_pointer_cast<CSSStyleDeclarationImp>(style.self())) {
        if (getLocalName() == u"center")
            imp->setHTMLAlign(u"center");
    }
    return style;
}

void HTMLDivElementImp::handleMutation(events::MutationEvent mutation)
{
    std::u16string value = mutation.getNewValue();
    css::CSSStyleDeclaration style(getStyle());

    switch (Intern(mutation.getAttrName().c_str())) {
    case Intern(u"align"):
        if (auto imp = std::dynamic_pointer_cast<CSSStyleDeclarationImp>(style.self()))
            imp->setHTMLAlign(value);
        break;
    default:
        HTMLElementImp::handleMutation(mutation);
        break;
    }
}

std::u16string HTMLDivElementImp::getAlign()
{
    return getAttribute(u"align");
}

void HTMLDivElementImp::setAlign(const std::u16string& align)
{
    setAttribute(u"align", align);
}

}
}
}
}

max_stars_repo_name: esrille/escudo

max_issues_repo_name: esrille/escudo

max_forks_repo_name: esrille/escudo


text:
#ifndef PYTHONIC_INCLUDE_NUMPY_FLOOR_HPP
#define PYTHONIC_INCLUDE_NUMPY_FLOOR_HPP

#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/utils/numpy_traits.hpp"
#include <boost/simd/function/floor.hpp>

PYTHONIC_NS_BEGIN

namespace numpy
{
#define NUMPY_NARY_FUNC_NAME floor
#define NUMPY_NARY_FUNC_SYM boost::simd::floor
#include "pythonic/include/types/numpy_nary_expr.hpp"
}
PYTHONIC_NS_END

#endif

max_stars_repo_name: SylvainCorlay/pythran

max_issues_repo_name: SylvainCorlay/pythran

max_forks_repo_name: SylvainCorlay/pythran


text:
//
// Created by _as on 2019-04-06.
//

// Wrapper code

#include <fstream>
#include <memory>
#include <string>
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <rapidjson/rapidjson.h>
#include <rapidjson/istreamwrapper.h>
#include "py_lnk.hpp"

using namespace boost::python;

class Wrapper {
  std::shared_ptr<rapidjson::Document> doc{};
  std::vector<Polygon> vec;
public:
  Wrapper(){
    doc = std::make_shared<rapidjson::Document>();
  }
  Wrapper(const Wrapper&) = default;
  Wrapper(Wrapper&&) = default;
  void ld_file(const char* fpath){
    std::ifstream in_file{fpath};
    rapidjson::IStreamWrapper isw(in_file);
    doc->ParseStream(isw);
  }
  void extract(unsigned u){
    vec = poly_extract(*doc, u);
    vec.erase(std::remove(vec.begin(), vec.end(), std::vector<Vertex>{}));
  }
  float diff(unsigned a, unsigned b){
    return differ(vec[a], vec[b]);
  }
};

BOOST_PYTHON_MODULE(pyExDiff){
  class_<sf::Vertex>("Vertex")
      .def("x", +[](sf::Vertex* v){return v->position.x;})
      .def("x", +[](sf::Vertex* v, float val){v->position.x = val;})
      .def("y", +[](sf::Vertex* v){return v->position.y;})
      .def("y", +[](sf::Vertex* v, float val){v->position.y = val;});
  class_<Polygon>("Polygon")
      .def(vector_indexing_suite<std::vector<float>>());
  class_<std::vector<Polygon>>("PolygonVec")
      .def(vector_indexing_suite<std::vector<Polygon>>());
  class_<Wrapper>("Wrap")
      .def("ldfile", &Wrapper::ld_file)
      .def("extract", &Wrapper::extract)
      .def("diff", &Wrapper::diff);
}

max_stars_repo_name: opensciencehack/Fork-of-Team-TimSort

max_issues_repo_name: opensciencehack/Fork-of-Team-TimSort

max_forks_repo_name: opensciencehack/Fork-of-Team-TimSort


text:
/*
   Copyright (c) Marshall Clow 2014.

   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)

    For more information, see http://www.boost.org
*/

#include <iostream>
#include <functional>

#include <boost/config.hpp>
#include <boost/algorithm/algorithm.hpp>

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>

namespace ba = boost::algorithm;

void test_power ()
{
    BOOST_CHECK ( ba::power(0, 0) == 1);
    BOOST_CHECK ( ba::power(5, 0) == 1);
    BOOST_CHECK ( ba::power(1, 1) == 1);
    BOOST_CHECK ( ba::power(1, 4) == 1);
    BOOST_CHECK ( ba::power(3, 2) == 9);
    BOOST_CHECK ( ba::power(2, 3) == 8);
    BOOST_CHECK ( ba::power(3, 3) == 27);
    BOOST_CHECK ( ba::power(2, 30) == 0x40000000);
    BOOST_CHECK ( ba::power(5L, 10) == 3125*3125);
    BOOST_CHECK ( ba::power(18, 3) == 18*18*18);

    BOOST_CHECK ( ba::power(3,2) == ba::power(3,2, std::multiplies<int>()));
    BOOST_CHECK ( ba::power(3,2, std::plus<int>()) == 6);
}

void test_power_constexpr ()
{
    BOOST_CXX14_CONSTEXPR bool check_zero_power1 =
        ba::power(0, 0) == 1;
    BOOST_CHECK(check_zero_power1);
    BOOST_CXX14_CONSTEXPR bool check_zero_power2 =
        ba::power(5, 0) == 1;
    BOOST_CHECK(check_zero_power2);
    BOOST_CXX14_CONSTEXPR bool check_one_base1 =
        ba::power(1, 1) == 1;
    BOOST_CHECK(check_one_base1);
    BOOST_CXX14_CONSTEXPR bool check_one_base2 =
        ba::power(1, 4) == 1;
    BOOST_CHECK(check_one_base2);
    BOOST_CXX14_CONSTEXPR bool check_power1 =
        ba::power(3, 2) == 9;
    BOOST_CHECK(check_power1);
    BOOST_CXX14_CONSTEXPR bool check_power2 =
        ba::power(2, 3) == 8;
    BOOST_CHECK(check_power2);
    BOOST_CXX14_CONSTEXPR bool check_power3 =
        ba::power(3, 3) == 27;
    BOOST_CHECK(check_power3);
    BOOST_CXX14_CONSTEXPR bool check_power4 =
        ba::power(2, 30) == 0x40000000;
    BOOST_CHECK(check_power4);
    BOOST_CXX14_CONSTEXPR bool check_power5 =
        ba::power(5L, 10) == 3125*3125;
    BOOST_CHECK(check_power5);
    BOOST_CXX14_CONSTEXPR bool check_power6 =
        ba::power(18, 3) == 18*18*18;
    BOOST_CHECK(check_power6);

    BOOST_CXX14_CONSTEXPR bool check_multiple =
        ba::power(3, 2, std::multiplies<int>()) == ba::power(3, 2);
    BOOST_CHECK(check_multiple);
    BOOST_CXX14_CONSTEXPR bool check_plus =
        ba::power(3, 2, std::plus<int>()) == 6;
    BOOST_CHECK(check_plus);
}

BOOST_AUTO_TEST_CASE( test_main ) {
  test_power ();
  test_power_constexpr ();
}

max_issues_repo_name: avplayer/cxxrpc

max_forks_repo_name: avplayer/cxxrpc