Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Content Count

  • Joined

  • Last visited


This user doesn't have any awards

1 Follower

About Unimportant

  • Title

Recent Profile Visitors

2,093 profile views
  1. Have you tried connecting it to 110V AC to check if it works ? Looks like it might be a flyback current regulator design which can possibly boost voltage aswell.
  2. That's the most likely option. The fact it took so much longer on the second system and it had to be aborted supports the view that it missed the 100000 mark.
  3. It depends on the PSU in question. More expensive higher end PSU's create a single 12V in the flyback section, which is then further converted to 5V and 3.3V using DC/DC converters. On such a PSU you can use the 5V rails and leave the 12V unused without problems. Other PSU's however, create all rails in the flyback section, but only a single rail can be used for regulation. This is usually the 12V rail. Using only the 5V rail in such a PSU, without using the 12V rail, might cause poor regulation on said 5V line.
  4. Are you sure someone removed those parts? Having unpopulated positions is not uncommon.
  5. The function keys are often used in debuggers for "step over", "step into", etc. You'll probably spend a lot of time in a debugger so ...
  6. Probably a power supply problem. The degaussing you hear is handled via a posistor and works even with a broken power supply.
  7. Why? One does not dynamically allocate memory without a good reason.
  8. Into a vector I'll assume, as array sizes are fixed at compile time. #include <iostream> #include <string> #include <algorithm> #include <sstream> #include <iterator> #include <vector> int main() { std::string exampleString = "{2.5, 3.5, 36.4}"; //Test if string begins with { and ends with }. if (exampleString.front() != '{' || exampleString.back() != '}') { std::cout << "String does not begin with '{' and/or end with '}'\n"; return 1; } //Replace {} and comma's with whitespace. exampleString.front() = exampleString.back() = ' '; std::replace(exampleString.begin(), exampleString.end(), ',', ' '); //Create stringstream from string. auto iss = std::istringstream(exampleString); //Create vector of doubles from stringstream. const auto doublesVector = std::vector<double>(std::istream_iterator<double>(iss), std::istream_iterator<double>()); //Check for errors. if (!iss && !iss.eof()) { std::cout << "Error parsing string.\n"; return 2; } //Print result. for (const auto d : doublesVector) { std::cout << d << ' '; } return 0; }
  9. You'll need one for testing/debugging. Expierenced engineers need multiple spins, testing and measuring, before they get it right. You're going to get it right first time without any testing ?
  10. Doable in the same way it's doable to put a man on the moon... Not something you're going to be doing as a hobbyist. A cheap oscilloscope with the required bandwidth will set one back the price of a nice car - We're talking pico-second rise and fall times here (= harmonics to the moon).
  11. So? I don't see K&R anywhere assisting me when I have to deal with the countless problems caused by omitting the brackets. I said nothing about using/not using temporary variables. I said to not declare all variables in the top of a function asif this was old C code. E.g. This: //Some code... const auto length = ... const auto width = ... const auto surface = length * width; rather then this: int length = 0; int width = 0; int surface = 0; //Some code ... length = ... width = ... surface = length * width; You declare variables at the point you need them, not in the top of the function asif old C.
  12. The problem is that a lambda cannot be converted to a function pointer if it has a capture. A solution would be to wrap the callbacks in std::function. However, std::function's cannot be stored in a std::unordered_set as unordered_set relies on std::hash and std::equal_to, both of which don't operate on std::function. Small example using std::vector instead: #include <functional> #include <vector> #include <iostream> template <class... Params> class Event { public: template <class T> using MemberPtr = void (T::*)(Params...); using Callback = std::function<void(Params...)>; template <class T> void Subscribe(T* t, MemberPtr<T> m) { const auto lambda = [=](Params&&... params) { (t->*m)(std::forward<Params>(params)...); }; Addcallback(lambda); } void Notify(Params&&... params) const { for (const auto& callback : mCallbacks) { callback(std::forward<Params>(params)...); } } private: void Addcallback(Callback callback) { mCallbacks.emplace_back(callback); } std::vector<Callback> mCallbacks; }; struct EventListener { void eventListenerCallback(int i) { std::cout << "Received " << i << std::endl; } }; struct DoublingListener { void eventListenerCallback(int i) { std::cout << "Double of received value " << i * 2 << std::endl; } }; int main() { Event<int> event; EventListener listener; DoublingListener doublingListener; event.Subscribe(&listener, &EventListener::eventListenerCallback); event.Subscribe(&doublingListener, &DoublingListener::eventListenerCallback); event.Notify(1337); return 0; }
  13. Simpler implementation of that logic: #include <iostream> #include <string> using namespace std; int main() { const auto numLines = 10; for (int i = 0; i < numLines; ++i) { cout << string(numLines - i - 1, ' ') << string(i * 2 + 1 , '*') << '\n'; } return 0; }