header-only Questions

2

Solved

I am writing a C++ library (header-only) and am using CMake to generate my (Visual Studio) project and solution files. I'm also writing a test suite, which is part of the same CMake project. My pr...
Subdeacon asked 4/9, 2014 at 23:2

2

I have a main.cpp including a.h (that has its own a.cpp) a.h includes the header only library "stbi_image.h" as such: #ifndef STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION #include "st...
Yang asked 11/4, 2017 at 14:26

5

Solved

I have a header-only library project set up with the cmake command: add_library(my_library INTERFACE) and I also added target_sources(my_library INTERFACE ${MY_LIRBARY_HEADER_FILES}) but whe...
Boudicca asked 15/9, 2017 at 18:42

3

Solved

I've ran into a confusion about how to properly use header-only library. Googling didn't help as I didn't find anything about using header-only libraries. So my question is: Should I just copy the...
Mcmullin asked 26/8, 2015 at 11:28

0

What is the correct way to implement a printable class in C++ if one wants to avoid processing iostream as much as possible? This question raises from the interaction between iostream, iosfwd with ...
Equipotential asked 24/9, 2021 at 22:40

3

Solved

I know it is possible to use the fmt formatting library in header-only mode: How to use fmt library in the header-only mode? but - why isn't it just header-only, period? That is, what's the benefit...
Elmore asked 15/6, 2021 at 20:32

5

Solved

What are the benefits of a header only library and why would you write it that way oppose to putting the implementation into separate file?
Opposite asked 1/10, 2012 at 10:15

3

Solved

What is the best way to have a static member in a non-templated library class, without placing the burden of defining the member on the class user? Say I want to provide this class: class i...
Cordovan asked 29/7, 2012 at 14:6

1

Solved

I have a header-only C++ library that I use in my Python extensions. I would like to be able to install them to Python's include path, such that I can compile extensions very easily with python3 se...
Monkfish asked 30/4, 2018 at 13:38

2

Solved

Some boost libraries are header-only, some are not, and for various reasons etc. Is there a specific reason/design decision why Boost.ProgramOptions is not header-only? I'm wondering becaus...
Praline asked 15/3, 2017 at 13:49

1

Solved

I have a few small header-only libraries (the header-only part is important). In the initial versions, I had some static members in the classes defined therein. It didn't occur to me until later (w...
Epicalyx asked 10/8, 2017 at 12:25

3

I have a library that needs to carry some constant data injected from the content of non-source files (in this case, OpenGL shader code). To achieve this, I'm using add_custom_command() to generate...
Sandell asked 10/2, 2015 at 0:15

2

Solved

I am developing a library that will consist of header files only. So far, it contains only classes, which has been fine. However, I have come to a point where I need to have some library-wide acces...
Cordell asked 6/9, 2012 at 17:47

2

Some time ago I started a big header library in C++1x using XCode. The current layout of the library is () something like (partial output from ls -R sponf) sponf/sponf: ancestors sponf.h sponf_util...
Anaclitic asked 11/2, 2015 at 8:20

7

Solved

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 ...
Dredge asked 1/9, 2014 at 13:15

4

Solved

Is there ever such a pattern of dependancies that it is impossible to keep everything in header files only? What if we enforced a rule of one class per header only? For the purposes of this questi...
Trocar asked 20/9, 2010 at 17:13

1

Solved

I'd like to write a C++ library which is not-header-only by default but could be used as a header only library defining a NOLIB macro. I've seen two approaches: inline definitions foo.h #if !...
Katowice asked 24/4, 2014 at 13:1

3

Solved

I've tried to find an answer to this using SO. There are a number of questions that list the various pros and cons of building a header-only library in c++, but I haven't been able to find one that...
Hampton asked 5/9, 2012 at 22:23

9

Solved

Looking at this project (http://www.savarese.com/software/libssrckdtree/) I found the definition "C++ header-only template library". At the moment I have basic C++ knowledge but would like to know ...
Forefend asked 1/6, 2011 at 11:58

4

Solved

Obviously template libraries need to be header only, but for non-templates, when should you make things header-only?
Voice asked 28/5, 2011 at 22:48

4

Solved

It seems like I had to inline quite a bit of code here. I'm wondering if it's bad design practice to leave this entirely in a header file like this: #include <list> #include <string> #...
Lennalennard asked 7/4, 2010 at 19:14

4

Solved

I'd like to package a library I'm working on as a header-only library to make it easier for clients to use. (It's small and there's really no reason to put it into a separate translation unit) Howe...
Scribe asked 8/2, 2010 at 22:39
1

© 2022 - 2024 — McMap. All rights reserved.