c++ now: cpp/c++ code using utxcpp and boost::phoenix

This program creates a random triangle, and calculate the distance of every two vertices of it.

API Used:

  • utx::print
  • utx::print_all
    (uphx::print_all)
  • utx::random
    (uphx::random)
  • std::ranges::for_each
  • phx::for_each
    (boost::phoenix::for_each)
  • phx::lambda
    (boost::phoenix::lambda)
  • utx::sqrt
  • utx::cbrt
    (uphx::cbrt)
  • utx::pown

Utxcpp Docs

#include <utxcpp/core.hpp>
#include <utxcpp/phoenix.hpp>
#include <boost/phoenix.hpp>

using phx::arg_names::arg1;
using phx::local_names::_x;

int main()
{
	// Declare a 3D triangle.
	std::array<std::array<utx::f32,3>,3> triangle;

	// Nested Range Algorithm (aka std::ranges::for_each and utx::random/uphx::random)
	std::ranges::for_each(
		triangle,
		uphx::random(arg1)
	);

	// Nested For Each
	std::ranges::for_each(
		triangle,
		phx::for_each(arg1, phx::lambda[arg1=uphx::cbrt(arg1)])
	);

	utx::print("triangle:");
	std::ranges::for_each(triangle, uphx::print_all(arg1));
	utx::print();

	auto distance = [] (auto & p1, auto & p2)
	{
		return utx::sqrt(
			utx::pown(p1[0]-p2[0], 2)
				+ utx::pown(p1[1]-p2[1], 2)
					+ utx::pown(p1[2]-p2[2], 2)
		);
	};

	utx::print("triangle vertex distances =>\n", distance(triangle[0], triangle[1]),
		distance(triangle[1], triangle[2]), distance(triangle[2], triangle[0]));
}

One possible output:

triangle:
5.678462 -3.314425 9.974591
-5.722333 -7.336027 -9.926257
8.361337 4.314020 6.393945

triangle vertex distances =>
23.285084 24.503517 8.843756

Utxcpp

Utxcpp is a simple and easy to use
library for cpp/c++, which requires
c++20/c++23, boost libraries and b2 build.

Enter

Utxcpp Docs

API documentation about how to
understand and use utxcpp library
for you.

Enter

Nirtcpp

Nirtcpp is a graphics and game
engine forked from irrlicht.

Enter

fxcmdutils

fxcmdutils -
Some commandline programs
to let us more easily and quickly
to use some features.

Enter

B2 Build

B2 is an easy to use and very
powerful cpp/c++ project
build system.

Enter