FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added mega project pack location and some tests · s-kramer/cpp_tests@fe5abb2 · GitHub

Commit fe5abb2

Browse files
committed
Added mega project pack location and some tests
1 parent 8b87a59 commit fe5abb2

12 files changed

Lines changed: 373 additions & 0 deletions

‎mega_project_pack/README.md‎

Lines changed: 244 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ifndef BOOST_BUILD_PCH_ENABLED
2+
#define BOOST_BUILD_PCH_ENABLED
3+
#include <boost/test/included/unit_test.hpp>
4+
#endif
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
double getPiNthDigit(int digits)
2+
{
3+
return 3;
4+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef GET_PI_NTH_DIGIT
2+
#define GET_PI_NTH_DIGIT
3+
4+
double getPiNthDigit(int digits);
5+
6+
#endif
62.9 KB
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#define BOOST_TEST_DYN_LINK
2+
#define BOOST_TEST_MODULE examples
3+
#include <boost/test/unit_test.hpp>
4+
#include "find_nth_pi_digit.h"
5+
6+
BOOST_AUTO_TEST_CASE(pi_digits)
7+
{
8+
BOOST_CHECK_EQUAL(getPiNthDigit(0), 3);
9+
BOOST_CHECK_CLOSE(5.0001, 5 + 0.001, 0.02);
10+
}

‎t87_rvalue_in_cpp03‎

7.55 KB
Binary file not shown.

‎t87_rvalue_in_cpp03.cpp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <iostream>
2+
3+
class Foo
4+
{
5+
public:
6+
explicit Foo (void) {};
7+
Foo(Foo&& rhs)
8+
{
9+
std::cout << "Inside of a move ctr" << '\n';
10+
}
11+
private:
12+
};
13+
14+
int main()
15+
{
16+
Foo f;
17+
18+
return 0;
19+
}

‎t88_map_bracket_operator_to_bool‎

56 KB
Binary file not shown.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <iostream>
2+
#include <unordered_map>
3+
#include <memory>
4+
#include <string>
5+
6+
class Base
7+
{
8+
public:
9+
explicit Base (void) = default;
10+
virtual ~Base () = default;
11+
12+
Base (const Base&) = delete;
13+
Base (const Base&&) = delete;
14+
Base operator=(const Base&) = delete;
15+
Base operator=(const Base&&) = delete;
16+
};
17+
18+
template <typename T>
19+
T* getHashedT(const std::string& key, std::unordered_map<std::string, std::unique_ptr<T>>& map)
20+
{
21+
std::unique_ptr<T>& entry = map[key];
22+
if (entry)
23+
{
24+
return entry.get();
25+
}
26+
27+
entry = std::make_unique<T>();
28+
return entry.get();
29+
}
30+
31+
template <typename T>
32+
T* getHashetTInsertVersion(const std::string& key, std::unordered_map<std::string, std::unique_ptr<T>>& m)
33+
{
34+
// This creates a pair (passed a string and creates unique_ptr and Base object at every lookup)
35+
auto r = m.insert(std::make_pair<std::string, std::unique_ptr<T>>(key, nullptr));
36+
if (r.first)
37+
{
38+
r.second = std::make_unique<T>();
39+
}
40+
return r.second.get();
41+
}
42+
43+
int main()
44+
{
45+
std::unordered_map<std::string, std::unique_ptr<Base>> m;
46+
auto b = getHashedT("first", m);
47+
48+
return 0;
49+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL