algorithms icon indicating copy to clipboard operation
algorithms copied to clipboard

Update bubble_sort.h

Open Pranay711 opened this issue 5 years ago • 3 comments

Bubble sort using template and funtion in c++. @pierredavidbelanger @Samana @blackball @wycg1984

Pranay711 avatar Oct 01 '20 11:10 Pranay711

Since I am tagged, I will say something.

I am not sure its a good idea to include bits/stdc++, I was told a couple of time that this is not a good practice. And anyways, using clang++ (the default for this project), it does not compile out of the box:

$ make bubble_sort_demo 
clang++ -g -Wall -Wno-unused-function -o bubble_sort_demo src/bubble_sort_demo.cpp -I./include -I. -lm
In file included from src/bubble_sort_demo.cpp:6:
./include/bubble_sort.h:26:10: fatal error: 'bits/stdc++' file not found
#include <bits/stdc++>
         ^~~~~~~~~~~~~
1 error generated.
make: *** [Makefile:245: bubble_sort_demo] Error 1

Also, src/bubble_sort_demo.cpp will expect the right namespace and function signature here

Do you care to explain what you are trying to achieve ?

Have a nice day :)

pierredavidbelanger avatar Oct 01 '20 12:10 pierredavidbelanger

From my point of view, it is not an improvement to

  • break public contract (the signature changed from alg::BubbleSort(T[], int, int) to std::bubble(X*, int))
  • include unknown header so the project does not compile (fatal error: 'bits/stdc++' file not found).

I feel I am missing something here, I will leave let others review this PR.

pierredavidbelanger avatar Oct 01 '20 13:10 pierredavidbelanger

In many compilers bits/stdc++ compiles and in some compiler bits/stdc++.h compiles.

On Thu, 1 Oct 2020, 6:37 pm Pierre-David Bélanger, [email protected] wrote:

From my point of view, it is not an improvement to

  • break public contract (the signature changed from alg::BubbleSort(T[], int, int) to std::bubble(X*, int))
  • include unknown header so the project does not compile (fatal error: 'bits/stdc++' file not found).

I feel I am missing something here, I will leave let others review this PR.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xtaci/algorithms/pull/153#issuecomment-702121580, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ6S7C3WZTAC7E42B4IR4RTSIR5HZANCNFSM4SAKC5PQ .

Pranay711 avatar Oct 01 '20 13:10 Pranay711