File tree 5 files changed +130
-1
lines changed
5 files changed +130
-1
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"cSpell.words" : [
3
3
" dylib" ,
4
+ " EENS" ,
4
5
" endforeach" ,
5
6
" endfunction" ,
7
+ " Kahan" ,
6
8
" qmlc" ,
7
9
" qmlcache" ,
8
10
" qmlproject" ,
Original file line number Diff line number Diff line change
1
+ # language: CMake
2
+
3
+ include (${REPO_FOLDER} /settings.cmake)
4
+
5
+ # Libraries
6
+
7
+ # find_package()
8
+ # add_library()
9
+ set (GLOBAL_LIBS)
10
+
11
+ # Add executable
12
+ file (GLOB_RECURSE SUBDIRS LIST_DIRECTORIES true "." )
13
+
14
+ string (REPLACE ";" "|" PREFIX "${TASK_PREFIXES} " )
15
+
16
+ foreach (SUBDIR ${SUBDIRS} )
17
+ if (IS_DIRECTORY ${SUBDIR} )
18
+ if ("${SUBDIR} " MATCHES "${PROJECT_NAME} /(${PREFIX} )[^/]*$" )
19
+ get_filename_component (SUBPROJECT_NAME ${SUBDIR} NAME )
20
+ set (SUBPROJECT_NAME "${PROJECT_NAME} _${SUBPROJECT_NAME} " )
21
+
22
+ # (files only in one subfolder)
23
+ file (GLOB SUBPROJECT_SOURCES
24
+ ${SUBDIR} /${HEADERS_FORMAT}
25
+ ${SUBDIR} /${SOURCES_FORMAT}
26
+ )
27
+
28
+ set (SUBPROJECT_SOURCES)
29
+
30
+ foreach (ITEM_HEADER IN LISTS HEADERS_FORMAT)
31
+ file (GLOB ITEM_HEADER_FORMAT_SOURCES ${SUBDIR} /${ITEM_HEADER} )
32
+ list (APPEND SUBPROJECT_SOURCES ${ITEM_HEADER_FORMAT_SOURCES} )
33
+ endforeach ()
34
+
35
+ foreach (ITEM_SOURCE IN LISTS SOURCES_FORMAT)
36
+ file (GLOB ITEM_SOURCE_FORMAT_SOURCES ${SUBDIR} /${ITEM_SOURCE} )
37
+ list (APPEND SUBPROJECT_SOURCES ${ITEM_SOURCE_FORMAT_SOURCES} )
38
+ endforeach ()
39
+
40
+ add_executable (${SUBPROJECT_NAME} ${SUBPROJECT_SOURCES} )
41
+
42
+ target_link_libraries (${SUBPROJECT_NAME} PRIVATE ${LIB_NAME} ${GLOBAL_LIBS} )
43
+ target_include_directories (${SUBPROJECT_NAME} PRIVATE ${REPO_FOLDER} /${LIB_NAME} )
44
+ endif ()
45
+ endif ()
46
+ endforeach ()
47
+
48
+ # For this project
49
+ CopyExtraFiles({})
Original file line number Diff line number Diff line change
1
+ # Lesson 6: 14.03.2025
2
+
3
+ SFINAE
Original file line number Diff line number Diff line change
1
+ #include " utils.hpp"
2
+
3
+ class Simple {
4
+ public:
5
+ Simple (int var) : var_(var) {}
6
+ bool DoSomething () const { return true ; }
7
+ bool DoSomething2 () const { return var_ > 2 ; }
8
+
9
+ private:
10
+ int var_;
11
+ };
12
+
13
+ inline bool SimpleDoSomething (Simple* s) { return s->DoSomething (); }
14
+
15
+ inline float KahanSummation (float sum_previous, float input,
16
+ float & accumulator) {
17
+ IC (sum_previous, input, accumulator);
18
+
19
+ ICDouble (sum_previous);
20
+ ICDouble (input);
21
+ ICDouble (accumulator);
22
+
23
+ const float y = input - accumulator;
24
+ ICDouble (y);
25
+
26
+ const float t = sum_previous + y;
27
+ ICDouble (t);
28
+
29
+ accumulator = (t - sum_previous) - y;
30
+
31
+ ICDouble (t - sum_previous);
32
+ ICDouble (accumulator);
33
+
34
+ return t;
35
+ }
36
+
37
+ int main () {
38
+ bool b_1 = true ;
39
+ bool b_2 = false ;
40
+
41
+ int a = 10 ;
42
+ auto * ptr = new Simple (a);
43
+ delete ptr;
44
+
45
+ ptr = nullptr ;
46
+
47
+ if (b_1 && b_2) {
48
+ }
49
+
50
+ ptr->DoSomething (); // пока метод не затрагивает поля класса, его можно
51
+ // вызывать даже с nullptr
52
+
53
+ // std::cout <<
54
+ ptr->DoSomething2 (); // с -O2 компилятор вырезает эту строку, иначе это seg
55
+ // fault
56
+ // << std::endl;
57
+
58
+ // if (ptr && ptr->DoSomething()) {
59
+ // }
60
+
61
+ auto accumulator = 0 .F ;
62
+ auto kh_s = KahanSummation (10 .33F , 0 .47F , accumulator);
63
+ ICDouble (kh_s);
64
+
65
+ return 0 ;
66
+ }
Original file line number Diff line number Diff line change 2
2
3
3
#include < cxxabi.h>
4
4
5
+ #include < iomanip>
5
6
#include < iostream>
6
7
#include < memory>
7
8
#include < type_traits>
11
12
12
13
#ifndef IC_TYPE
13
14
#define IC_TYPE (x ) IC(x, detail::TypeName<decltype(x)>())
15
+ #endif
14
16
17
+ #ifndef ICDouble
18
+ #define ICDouble (value ) \
19
+ { \
20
+ std::stringstream ss; \
21
+ ss << std::fixed << std::setprecision (19 ) << (value); \
22
+ IC (value, ss.str ()); \
23
+ }
15
24
#endif
16
25
17
26
namespace detail {
@@ -69,4 +78,4 @@ void PrintVerboseVarInfo(const T& value) {
69
78
IC_TYPE (value);
70
79
std::cout << " --------------------------------------------------"
71
80
<< std::endl;
72
- }
81
+ }
You can’t perform that action at this time.
0 commit comments