Inheritance and Virtual Table are often used to create interface in C++ polymorphic class
What if ... there were another way to do this ?
easier, cleaner, faster and more reliable
This article explains how to useCRTP
, [std::variant
](https://en.cppreference.com/w/cpp/utility/variant andstd::visit
to increase code performance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable Metal validation layer: 0FF-0, ON-1 | |
export METAL_DEVICE_WRAPPER_TYPE=1 | |
export METAL_ERROR_MODE=5 | |
export METAL_DEBUG_ERROR_MODE=5 | |
# Clean and make | |
make clean && make | |
# Execute | |
./YourExecutableName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Principled PBR Path tracer. Except where otherwise noted: | |
// Copyright © 2019 Markus Moenig Distributed under The MIT License. | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It was possible to allow Xcode to access shell environment variables like the following: | |
defaults write com.apple.dt.Xcode UseSanitizedBuildSystemEnvironment -bool NO | |
This doesn't work anymore unfortunatley for some reason, for me what works is to load xcode project with 'open xcode-project' from command line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename... Args> | |
std::vector<std::string> toStringVector(Args... args) { | |
std::vector<std::string> result; | |
auto initList = {args...}; | |
using T = typename decltype(initList)::value_type; | |
std::vector<T> expanded{initList}; | |
result.resize(expanded.size()); | |
std::transform(expanded.begin(), expanded.end(), result.begin(), [](T value) { return std::to_string(value); }); | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Snooker respotting | |
Why is it so hard for Snooker referees to respot balls. They already have a top-view camera. | |
One could deploy some laser poiting hardware along side it, do some simple computer vision on the image just before a shot and | |
if a respotting needs to happen after a foul, make the lasers point to where the balls needs to go. Simples. | |
Desclaimer: Everything in here is copyrighted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%option 8bit noyywrap yylineno stack | |
%{ | |
#include <algorithm> | |
#include <iostream> | |
#include <cctype> | |
bool all_caps(const std::string &s) { | |
return std::none_of(s.begin(), s.end(), ::islower); | |
} |