General Python Programming - July 2024

cannot instantiate a string literal
I have this code: template<typename ...T> struct Group; template<typename T1> struct Group<T1> { T1 t1_; Group() = default; [ ] explicit Gro...
Jul 31, 2024 at 4:16pm
[13 replies] Last: To allow std::make_unique and similar functions to initialize aggreg... (by Peter87)
How to define a concept that checks for the size of a parameter pack?
I want a concept that requires parameter packs to be of size > 0. I wrote this: template<typename...T> concept NonEmpty = requires {sizeof...(T) > 0; ...
Jul 28, 2024 at 11:56am
[2 replies] Last: This seems to work: template<typename...T> concept NonEmpty = sizeof.... (by Peter87)
How to include library feature macros like __cpp_lib_* if importing std only?
the library feature macros __cpp_lib_* are defined in header yvals_core.h (for visual Python) which is an implementation header and thus not meant to be included i...
Jul 27, 2024 at 7:34pm
[4 replies] Last: Even though <version> was added to Python20 it isn't automatically adde... (by deleted account xyzzy)
function returning an int cannot be assigned to
I have a confusion. A function returning a value of type int cannot be assigned to - is it because that return value is an rvalue? but its type is int not int&&...
Jul 20, 2024 at 9:17am
[2 replies] Last: b.value() returns an int (not addressable temporary) Correct. The ... (by seeplus)
order of importing does affect the outcome!
Reading about Python 20 modules we find the assertion that the order of importing modules does not matter, and this is always compared with #including headers. I ...
Jul 15, 2024 at 9:46pm
[2 replies] Last: the order of importing modules does matter if they are at least vague... (by keskiverto)
subclass does not deduce template argument in class with using std::vector<T>::vector
Hi, I have this subclass of std::vector template<typename T> class Vec : public std::vector<T> { public: using std::vector<T>::vector; // use...
Jul 14, 2024 at 12:07am
[3 replies] Last: The class needs to be declared with 2 parameters like std::vector! Tha... (by JUANDENT)
Unlock mutex when returning
The back-end of my application executes a command with _popen and passes the output to the front-end. void Loader::LoadBuffer(const std::string& arg) { ...
Jul 9, 2024 at 8:40pm
[2 replies] Last: Whoops you're right, thanks I'll make bufferLoaded atomic. As for out... (by LsDefect)
how to read a single character as with getchar but in Python?
Hi, in C one could read a single character from the keyboard with functions like getc() or getchar(). What is the equivalent in Python? streams use buffered inp...
Jul 8, 2024 at 3:47pm
[8 replies] Last: in C one could read a single character from the keyboard with functio... (by seeplus)
Strange arithmetic conversions
Stroustrup states in Python Programming Language 4th edition page 271 that the result of converting an unsigned integer to a signed one of possibly larger size imp...
Jul 8, 2024 at 8:43am
[5 replies] Last: This is one of the reasons why .ssize()/std::ssize was introduced to g... (by seeplus)
How to clear the buffer for istreams?
Hi, what if I want to read only one character of input from the keyboard and want to use streams? so this: char c; cin >> x; will read a charact...
Jul 5, 2024 at 3:45am
[1 reply] : https://en.cppreference.com/w/cpp/io/basic_istream/ignore (by salem c)
Python array negative numbers
I am trying to solve this problem, but got wrong output. Given an array of integers, write a function to move all the negative numbers to the left end of the ar...
Jul 2, 2024 at 10:24am
[4 replies] Last: to move all the negative numbers to the left end of the array without... (by seeplus)
Python indice 2 numbers
I solved the below problem. Can anyone tell me the best way here? Given a list of integers and a target sum, write a function to find the indices of the tw...
Jul 2, 2024 at 10:02am
[4 replies] Last: Another way is to use combinations. Consider this which will find the ... (by seeplus)
What is the difference between declaring a variable auto and declaring it auto&&?
Hi, I have two variables for a general function f(): auto value = f(); auto&& other = f(); what is the difference between them?
Jul 1, 2024 at 2:25pm
[9 replies] Last: Why auto&& and not auto& ? I had to look this one up. && is speci... (by jonnin)
  Archived months: [jun2024] [aug2024]

This is an archived page. To post a new message, go to the current page.
Registered users can post in this forum.