Skip to content

Instantly share code, notes, and snippets.

View Loki-Astari's full-sized avatar
😎
What's up?

Loki Astari Loki-Astari

😎
What's up?
View GitHub Profile
#include "AAA.h"
#include "ClassA.h"
size_t AAA:get_sSize() {
// Initialized on first use.
static size_t sSize = ClassA::Insert( "AAA" );
// return the value that is only initialized once.
return sSize;
}
> g++ -std=c++17 test.cpp
> ./a.out
Expect: Construct Normal
Construct Normal
Expect: Construct Copy
Constructor Copy
Expect: Construct Move
@Loki-Astari
Loki-Astari / md5.cpp
Last active September 19, 2022 19:57
#include "md5.h"
#include <iostream>
#include <cmath>
#include <bit>
const std::array<std::uint32_t, 64> pstl::cryptography::hashing::md5::s_array = {
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
namespace ThorsAnvil
{
class SomeThingWithResource
{
public:
// Construction / Destruction
SomeThingWithResource()
: // Initalize Resouces
{}
~SomeThingWithResource()
Not sure I understand the statement.
The type `T` is used to somehow load the configuration in some way?
class UConfigurableBase
{
public:
virtual json GetDefaultConfig() = 0;
bool Validate(const json& source );
}
struct der
{
private: // No resources :-(
int *p=new int[4]; // This is a resource.
// If you don't do anything it will leak.
public:
};
struct derWithDestructorOnly: public base
{
#include <string>
#include <iostream>
int main()
{
std::string s;
std::getline(std::cin, s); // Should check that worked.
int q;
std::cin >> q;
// See Simple Example https://github.com/Loki-Astari/ThorsSerializer/blob/master/doc/example1.md
#include <iostream>
#include <sstream>
#include <vector>
#include "ThorSerialize/Traits.h"
#include "ThorSerialize/JsonThor.h"
#include "ThorSerialize/SerUtil.h"
// Version 1
// Your version
// Two layers of indirection.
std::string** myArray = new string*[size]; // call to new must be matched with delete.
for (int loop; loop < size; ++loop) {
myArray[loop] = new string; // call to new must be matched with delete.
std::getline(std::cin, myArray[loop][0], '/');
std::getline(std::cin, myArray[loop][1]);
// Note I removed the header
.globl __Z4fibLi ## -- Begin function _Z4fibLi
.p2align 4, 0x90
__Z4fibLi: ## @_Z4fibLi
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp