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
// from Eric Niebler's talk from C++Now 2014 https://www.youtube.com/watch?v=zgOF4NrQllo | |
class RegularCxx11 { | |
RegularCxx11(); | |
RegularCxx11(RegularCxx11 const &); | |
RegularCxx11(RegularCxx11 &&) noexcept; | |
~RegularCxx11(); | |
RegularCxx11 & operator=(RegularCxx11 const &); | |
RegularCxx11 & operator=(RegularCxx11 &&) noexcept; | |
friend bool operator==(RegularCxx11 const &, RegularCxx11 const &); | |
friend bool operator!=(RegularCxx11 const &, RegularCxx11 const &); |
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
#==================================================================================================# | |
# # | |
# Copyright 2012 MaidSafe.net limited # | |
# # | |
# This MaidSafe Software is licensed to you under (1) the MaidSafe.net Commercial License, # | |
# version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which # | |
# licence you accepted on initial access to the Software (the "Licences"). # | |
# # | |
# By contributing code to the MaidSafe Software, or to this project generally, you agree to be # | |
# bound by the terms of the MaidSafe Contributor Agreement, version 1.0, found in the root # |
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<class T> | |
class Atomic { | |
private: | |
mutable T t; | |
mutable std::mutex m; | |
public: | |
Atomic( T t_ ) : t( t_ ) { } | |
template<typename F> | |
auto operator()( F f ) const -> decltype(f(t)) |
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
#ifndef MY_CLASS_H | |
#define MY_CLASS_H | |
#include <tuple> | |
#include <utility> | |
template <typename T, typename U> | |
struct MyClass { | |
T first; | |
U second; |
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
/* | |
* ===================================================================================== | |
* | |
* Filename: turing.cc | |
* | |
* Description: | |
* | |
* Version: 1.0 | |
* Created: 30/07/12 19:16:46 | |
* Revision: none |
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
/* | |
* ===================================================================================== | |
* | |
* Filename: max_template.cc | |
* | |
* Description: simple template example | |
* | |
* Version: 1.0 | |
* Created: 25/07/12 19:56:01 | |
* Revision: none |
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
// sfinae test for has ThisFunc() method | |
template <typename T> | |
class has_this_func { | |
typedef char one[1]; | |
typedef char two[2]; | |
template <typename U> static one test(decltype(&U::ThisFunc()); // could also be *U::Routing() for pointer to ThisFunc | |
// the above gets masked out as sfinae will choose two | |
template <typename U) static two test(...); | |
public: | |
static bool const value = sizeof(test<T>(0)) == sizeof(one); |
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
union Endian { | |
char c; | |
int i; | |
Endian(void) : i(1) { }; | |
bool big(void) { return !!c; }; | |
} endian; | |
cerr << (endian.big() ? "big" : "little"); |
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
#include <boost/program_options.hpp> | |
#include <thread> | |
#include <chrono> | |
#include <iostream> | |
namespace po = boost::program_options; | |
int main(int ac, char* av[]) { | |
po::options_description desc("Allowed options"); | |
desc.add_options() |
NewerOlder