Skip to content

Commit

Permalink
5 things to not bother in C++
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolasan committed Nov 24, 2024
1 parent c0da6eb commit 0d64990
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
6 changes: 4 additions & 2 deletions experimental/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ set(CMAKE_CXX_STANDARD 20)

# https://www.mssl.ucl.ac.uk/swift/om/sw/help/man/bfd_toc.html

add_executable(bfd-example bfd-example.cpp)
target_link_libraries(bfd-example bfd)
if(UNIX AND NOT APPLE)
add_executable(bfd-example bfd-example.cpp)
target_link_libraries(bfd-example bfd)
endif()
3 changes: 2 additions & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@

# Experimental

- [BFD]()
- [BFD]()
- [5 things to not bother in C++](./advanced/useless.md)
31 changes: 31 additions & 0 deletions src/advanced/useless.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 5 things to not bother in C++

## Pseudo destructors

```cpp
typedef int I;
int main() {
I x = 10;
x.I::~I();
x = 20;
}
```

[Built-in member access operators(https://en.cppreference.com/w/cpp/language/operator_member_access#Built-in_member_access_operators)

## ODR use

ODR use _something_ [so question](https://stackoverflow.com/questions/19630570/what-does-it-mean-to-odr-use-something)

```cpp
struct F {
static const int g_x = 2;
};

int g_x_plus_1 = F::g_x + 1; // in this context, only the value of g_x is needed.
// so it's OK without the definition of g_x

vector<int> vi;
vi.push_back( F::g_x ); // Error, this is odr-used, push_back(const int & t) expect
// a const lvalue, so it's definition must be present
```
6 changes: 5 additions & 1 deletion time/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
add_executable(2070_rtc 2070-rtc-limit.c)

if(UNIX AND NOT APPLE)
add_executable(2070_rtc 2070-rtc-limit.c)
endif()

add_executable(scheduler scheduler.cpp)

1 comment on commit 0d64990

@mikolasan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.