| Date | 05-05-2021 - 10-17-2023 |
| Revision | R3 |
| Author | Guillaume Dua |
| Reviewers | Loïc Joly, Antoine Morrier |
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::visitto increase code performance.
This file contains hidden or 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
| #include <bits/stdc++.h> | |
| using namespace std; | |
| struct node { | |
| int data{}; | |
| node* left = nullptr; | |
| node* right = nullptr; | |
| node* parent = nullptr; | |
| string color; | |
| }; |
This file contains hidden or 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
| // By your BOI : Yahia B | |
| // feel free to take whatever you would like | |
| #ifndef SkipList_H | |
| #define SkipList_H | |
| #include <iostream> | |
| #include <cstdlib> | |
| #include <limits> | |
| #include <random> | |
| #include <ctime> | |
| #include <vector> |
This file contains hidden or 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
| #pragma once | |
| #include <type_traits> | |
| #include <limits> | |
| // The default enumeration category. Conversion is equivalent to static_cast. | |
| // Unspecialized enumeration traits use this category. | |
| struct enum_default { }; | |
| // The standard-layout enumeration category. Values outside the given range are |
This file contains hidden or 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
| /** | |
| * @file endianness.h | |
| * @brief Convert Endianness of shorts, longs, long longs, regardless of architecture/OS | |
| * | |
| * Defines (without pulling in platform-specific network include headers): | |
| * bswap16, bswap32, bswap64, ntoh16, hton16, ntoh32 hton32, ntoh64, hton64 | |
| * | |
| * Should support linux / macos / solaris / windows. | |
| * Supports GCC (on any platform, including embedded), MSVC2015, and clang, | |
| * and should support intel, solaris, and ibm compilers as well. |
This file contains hidden or 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
| SELECT | |
| *, | |
| pg_size_pretty(table_bytes) AS table, | |
| pg_size_pretty(index_bytes) AS index, | |
| pg_size_pretty(total_bytes) AS total | |
| FROM ( | |
| SELECT | |
| *, total_bytes - index_bytes - COALESCE(toast_bytes, 0) AS table_bytes | |
| FROM ( | |
| SELECT |
A short demo showing the explicit instantiation of templates, and how to avoid parsing the full definition(s) in every compilation unit. The limitation is that it will only be possible to use the specific specialisations explicitly instantiated in the cpp file.
This file contains hidden or 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
| /*** | |
| * Excerpted from "The Definitive ANTLR 4 Reference", | |
| * published by The Pragmatic Bookshelf. | |
| * Copyrights apply to this code. It may not be used to create training material, | |
| * courses, books, articles, and the like. Contact us if you are in doubt. | |
| * We make no guarantees that this code is fit for any purpose. | |
| * Visit http://www.pragmaticprogrammer.com/titles/tpantlr2 for more book information. | |
| ***/ | |
| import org.antlr.v4.runtime.*; | |
| import org.antlr.v4.runtime.tree.ParseTree; |
This file contains hidden or 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
| -- Create a group | |
| CREATE ROLE readaccess; | |
| -- Grant access to existing tables | |
| GRANT USAGE ON SCHEMA public TO readaccess; | |
| GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; | |
| -- Grant access to future tables | |
| ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; |
NewerOlder