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 <iostream> | |
#include <sstream> | |
#include <vector> | |
namespace detail | |
{ | |
enum options { add, remove }; | |
class ctype : public std::ctype<char> | |
{ |
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 <iostream> | |
namespace custom | |
{ | |
struct sep_impl | |
{ | |
sep_impl(std::string const& separator); | |
std::string separator; | |
}; | |
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 <iostream> | |
#include <vector> | |
#include <string> | |
namespace detail | |
{ | |
template <int... Is> | |
struct index { }; | |
template <int N, int... Is> |
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 <iostream> | |
class stream_buffer : public std::streambuf | |
{ | |
public: | |
stream_buffer(std::ostream& os) | |
: whitespace(true), | |
ctype(std::use_facet<std::ctype<char>>(getloc())), | |
m_sbuf(os.rdbuf()) | |
{ } |
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 <iostream> | |
#include <sstream> | |
#include <typeinfo> | |
namespace detail | |
{ | |
template<int... Is> | |
struct index { }; | |
template<int N, int... Is> |
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
class num_get : public std::num_get<char> | |
{ | |
public: | |
// Override do_get which is a virtual function in the std::num_get<char> | |
// base class. It is called by the public member function get() in the | |
// implementation of std::basic_istream<charT>::operator>>(int&) | |
// You might want to put this into a helper function and call it in | |
// both the signed and unsigned overloads |
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 <locale> | |
template<class char> | |
class num_put : public std::num_put<char> | |
{ | |
using string_type = std::basic_string<char>; | |
string_type first_, second_; | |
public: | |
num_put(const string_type& first = string_type{}, |
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 <vector> | |
#include <sstream> | |
#include <string> | |
#include <algorithm> | |
#include <iterator> | |
template < | |
class Value, | |
class Container = std::vector<Value>, | |
class charT = char, |
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
// Answer: 233168 | |
int main() | |
{ | |
int sum(0); | |
for (int i = 0; i < 1000; ++i) { | |
if ((i % 3 == 0) || (i % 5 == 0)) sum += i; | |
} | |
} |
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
// Answer: 4,613,732 | |
unsigned int fib(unsigned int n) { | |
return n <= 1 ? n : fib(n-1) + fib(n-2); | |
} | |
int main() | |
{ | |
unsigned int sum(0); |