Questions tagged [library-design]

Use this tag for topic related to library development

Relates to designing and developing libraries, which can be used for private or public software development.

66 questions
32
votes
7 answers

Library design: allow user to decide between "header-only" and dynamically linked?

I have created several C++ libraries that currently are header-only. Both the interface and the implementation of my classes are written in the same .hpp file. I've recently started thinking that this kind of design is not very good: If the user…
Vittorio Romeo
  • 90,666
  • 33
  • 258
  • 416
30
votes
5 answers

Where are the readonly/const in .NET?

In C++ you'll see void func(const T& t) everywhere. However, i havent seen anything similar in .NET. Why? I have notice a nice amount of parameters using struct. But i see no functions with readonly/const. In fact now that i tried it i couldnt use…
user34537
25
votes
5 answers

Why doesn't the .Net framework have a priority queue class?

There are some threads on Stack Overflow dealing with implementing priority queues in .Net and C#. My issue is of a more basic nature: Why isn't there a priority queue out of the box in the .Net framework? Even the C++ Standard Library has one.
18
votes
2 answers

What's the purpose of Function.const?

It is in ScalaDoc but without much documentation. It seems that it always returns the first parameter. Function.const(1)(2) for instance returns 1. Why does it exist and why is it useful?
soc
  • 27,983
  • 20
  • 111
  • 215
18
votes
9 answers

Writing a library with C and C++ interfaces, which way to wrap?

When preparing a library (let's call it libfoo), I find myself presented with the following dilemma: do I write it as a C++ library with a C wrapper: namespace Foo { class Bar { ... }; } /* Separate C header. #ifdef __cplusplus omitted for…
Jack Kelly
  • 18,264
  • 2
  • 56
  • 81
17
votes
1 answer

Is there any reason for std::multiplies and std::divides to be in third person?

Today we discovered that the functors for multiplying and dividing, are called std::multiplies and std::divides, as opposed to, for example, std::multiply and std::divide respectively. This is surprising to say the least, considering that std::plus…
Shoe
  • 74,840
  • 36
  • 166
  • 272
16
votes
4 answers

Why generic IList<> does not inherit non-generic IList

IList does not inherit IList where IEnumerable inherits IEnumerable. If out modifier are the only reason then why most of the implementation of IList (e.g. Collection, List) implements IList interface. So any one can say OK, if…
Nafeez Abrar
  • 1,045
  • 10
  • 27
15
votes
3 answers

Why does TStringList have BeginUpdate and EndUpdate?

I understand that using BeginUpdate and EndUpdate on VCL controls such as TListBox speeds up the process of populating the control with Items as it prevents the control from being repainted, until EndUpdate is called. Example: procedure…
user1175743
15
votes
1 answer

Why do std::count(_if) return iterator::difference_type instead of size_t?

Possible Duplicate: Why does the C++ standard algorithm “count” return a ptrdiff_t instead of size_t? There is algorithm std::count/std::count_if in standard C++. template typename…
ForEveR
  • 55,233
  • 2
  • 119
  • 133
15
votes
2 answers

Why does std::fstream set the EOF bit the way it does?

I recently ran into a problem caused by using fstream::eof(). I read the following line from here: The function eof() returns true if the end of the associated input file has been reached, false otherwise. and (mistakenly) assumed this meant that…
Jeff Barger
  • 1,241
  • 1
  • 13
  • 19
12
votes
13 answers

Is requiring a certain order for #includes in c++ a sign of bad library/header design?

I've used some very large scale systems and never seen a required order, but came across it recently. Does the STL or STD library or even Boost have any cases where certain includes must come in a certain order?
ApplePieIsGood
  • 3,731
  • 6
  • 35
  • 51
11
votes
4 answers

An Object that returns an instance of itself

Background: My latest project cannot use a large library, which saddens me. There are a few things that I would like to have from any library such as the missing functions addClass, hasClass, removeClass, compatible addEventListener, etc. So I…
Levi Morrison
  • 19,116
  • 7
  • 65
  • 85
10
votes
5 answers

The mechanics of extension via free functions or member functions

Loads of C++ libraries, the standard included, allow you to adapt your objects for use in the libraries. The choice is often between a member function or a free function in the same namespace. I'd like to know mechanics and constructs the library…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
9
votes
2 answers

Order of Java 8's datetime package DayOfWeek enum

I was looking at the tutorial for Java 8's new datetime package. On the page about the DayOfWeek and Month enums, it said that the DayOfMonth enum runs from Monday to Sunday. Why is that? Every other system I've used (including .NET) has the week…
chama
  • 5,973
  • 14
  • 61
  • 77
8
votes
0 answers

Why is std::vector::max_size() non-static?

Since the maximum size does not depend on particular std::vector objects, I guess it should be a static method. But still, the standard prototypes it as non-static, and I cannot figure out why. Logically, one should check the maximum size before…
Lingxi
  • 14,579
  • 2
  • 37
  • 93
1
2 3 4 5