standard-library

string producer/consumer in C++: std::deque<char> or std::stringstream?

余生颓废 提交于 2019-12-11 01:06:19
问题 In our application we have a class that produces characters, and another that consumes them. The current implementation dynamically allocates characters as they are produced (using new ) and delete them (with delete ) as they are consumed. This is all terribly slow, and I am looking at ways to replace that implementation to improve its performance. The semantic I need is that of the standard class queue : push at the front, pop at the back. The default implementation uses a deque IIRC. deque

Scala DoubleLinkedList replacement

徘徊边缘 提交于 2019-12-11 00:28:57
问题 DoubleLinkedList is deprecated since Scala 2.11.0 (http://www.scala-lang.org/api/current/index.html#scala.collection.mutable.DoubleLinkedList$). Why is this? There doesn't seem to be a clear replacement for it. Is there any plans for a successor? 回答1: "Idiosyncratic and dangerous" API, as it is described in the commit message and deprecation, sums it up. The general direction has been to reduce the size of the standard library, and of collections in particular, so it's likely that a

How can I make sure there are a given number of threads at all times? (Also, is this a good usage of threads?)

荒凉一梦 提交于 2019-12-11 00:08:48
问题 I've just started diving into multithreading using the standard library today. Below is what I've come up with so far. Though it works in principle, it does not start a new thread once one has finished, but rather starts 4 threads once the last 4 finished, so if the tasks take an unequal amount of time, it isn't very efficient. Also, if they don't finish in the correct order, they have to wait for the succeeding work to finish until their results are evaluated. How could I achieve always

Is it acceptable to wrap PHP library functions solely to change the names?

ぐ巨炮叔叔 提交于 2019-12-10 21:42:19
问题 I'm going to be starting a fairly large PHP application this summer, on which I'll be the sole developer (so I don't have any coding conventions to conform to aside from my own). PHP 5.3 is a decent language IMO, despite the stupid namespace token. But one thing that has always bothered me about it is the standard library and its lack of a naming convention. So I'm curious, would it be seriously bad practice to wrap some of the most common standard library functions in my own functions

Linux C++ LD_LIBRARY_PATH suppressing standard libraries

两盒软妹~` 提交于 2019-12-10 19:34:08
问题 I'm kind of new to C++ although I have done some Objective C recently so some of it looks vaguely familiar. I'm in the process of writing some test programs to gauge whether something is going to be possible or not. In my (very simple 'Hello World') program I'm outputting some text using cout which works fine, however when I modify the LD_LIBRARY_PATH to point to some libraries required by a 3rd party application that I'll be communicating with I get no output but no compiler errors from g++.

Implement the C standard library in C++

点点圈 提交于 2019-12-10 16:37:36
问题 Say an OS/kernel is written with C++ in mind and does not "do" any pure C style stuff, but instead exposes the C standard library built upon a full-fledged C++ standard library. Is this possible? If not, why? PS: I know the C library is "part of C++", but let's say it's internally based on a C++-based implementation. Small update: It seems I've stirred up a discussion as to what is "allowed" by my rules here. Generally speaking: the C Standard library implementation should use C++ everwhere

Locale-invariant string processing with strtod strtof atof printf?

喜欢而已 提交于 2019-12-10 15:25:32
问题 Are there any plans for adding versions of C standard library string processing functions that are invariant under current locale? Currently there are lots of fragile workarounds, for example, from jansson/strconv.c: static void to_locale(strbuffer_t *strbuffer) { const char *point; char *pos; point = localeconv()->decimal_point; if(*point == '.') { /* No conversion needed */ return; } pos = strchr(strbuffer->value, '.'); if(pos) *pos = *point; } static void from_locale(char *buffer) { const

Lexicographic ordering of pairs/lists in Agda using the standard library

心已入冬 提交于 2019-12-10 15:18:25
问题 The Agda standard library contains some modules Relation.Binary.*.(Non)StrictLex (currently only for Product and List ). We can use these modules to easily construct an instance of, for example, IsStrictTotalOrder for pairs of natural numbers (i.e. ℕ × ℕ ). open import Data.Nat as ℕ using (ℕ; _<_) open import Data.Nat.Properties as ℕ open import Relation.Binary using (module StrictTotalOrder; IsStrictTotalOrder) open import Relation.Binary.PropositionalEquality using (_≡_) open import

Why doesn't Clang come with standard library headers?

痞子三分冷 提交于 2019-12-10 12:31:12
问题 I downloaded Clang 3.6.2 from this website and am trying to set it up with Code::Blocks under Windows. Unfortunately, it fails to compile a simple "hello world" program on the grounds that it doesn't know where iostream is. Looking through the install folder, it does not appear to include a standard library with it. Why? And how do I get it? 回答1: The standard library is NOT part of the compiler itself. It is part of the runtime environment on a particular platform. Sure, some organisations

Why were Haskell 98's standard classes made inferior to Haskell 1.3's?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 12:28:09
问题 Before Haskell 98, there were Haskell 1.0 through 1.4. It's pretty interesting to see the development throughout the years, as features were added to the earliest versions of standardized Haskell. For instance, the do-notation was first standardized by Haskell 1.3 (published 1996-05-01). In the Prelude , we find the following definitions (page 87): -- Monadic classes class Functor f where map :: (a -> b) -> f a -> f b class Monad m where (>>=) :: m a -> (a -> m b) -> m b (>>) :: m a -> m b ->