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 <thing> | |
void swap(Type<> i, Type<> j) { | |
t = i; | |
i = j; | |
j = t; | |
} | |
RetType<> merge_sort(Array_of_Type<> a, size_of_a) { | |
if (size_of_a > 1) { |
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
// The intent of this class is to display the layout of an object in | |
// memory. | |
// Compile with: | |
// clang -cc1 -x c++ -v -fdump-record-layouts test.cc -emit-llvm -o /dev/null | |
// | |
// | |
//*** Dumping AST Record Layout | |
//0 | struct Top | |
//0 | int a | |
//| [sizeof=4, dsize=4, align=4 |
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
// The example I've chosen is from here: | |
// http://en.cppreference.com/w/cpp/language/template_specialization | |
#include <iostream> | |
template<class T> // primary template | |
struct is_void : /*typename*/ std::false_type // Despite having a qualified name, typename is now allowed here. | |
// It leads to the error, error: keyword 'typename' not allowed in this context (the base class is implicitly a type) | |
{ | |
struct s | |
{ | |
}; |
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
//---------------------------------------------------------------------- | |
// Type deduction class. | |
struct s_td { // Do not make this a class template, unless the template | |
// is necessary for something other than echoval(...) | |
template <typename K> | |
void echoval(K&& t) // Universal reference. | |
{ | |
std::cout << "t = " << t << '\n'; | |
} | |
}; |