Abseil Common Libraries (C++)

Abseil - C++ Common Libraries

The repository contains the Abseil C++ library code. Abseil is an open-source collection of C++ code (compliant to C++11) designed to augment the C++ standard library.

Table of Contents

About Abseil

Abseil is an open-source collection of C++ library code designed to augment the C++ standard library. The Abseil library code is collected from Google's own C++ code base, has been extensively tested and used in production, and is the same code we depend on in our daily coding lives.

In some cases, Abseil provides pieces missing from the C++ standard; in others, Abseil provides alternatives to the standard for special needs we've found through usage in the Google code base. We denote those cases clearly within the library code we provide you.

Abseil is not meant to be a competitor to the standard library; we've just found that many of these utilities serve a purpose within our code base, and we now want to provide those resources to the C++ community as a whole.

Quickstart

If you want to just get started, make sure you at least run through the Abseil Quickstart. The Quickstart contains information about setting up your development environment, downloading the Abseil code, running tests, and getting a simple binary working.

Building Abseil

Bazel and CMake are the official build systems for Abseil.

See the quickstart for more information on building Abseil using the Bazel build system.

If you require CMake support, please check the CMake build instructions and CMake Quickstart.

Support

Abseil is officially supported on many platforms. See the Abseil platform support guide for details on supported operating systems, compilers, CPUs, etc.

Codemap

Abseil contains the following C++ library components:

  • base Abseil Fundamentals
    The base library contains initialization code and other code which all other Abseil code depends on. Code within base may not depend on any other code (other than the C++ standard library).
  • algorithm
    The algorithm library contains additions to the C++ library and container-based versions of such algorithms.
  • cleanup
    The cleanup library contains the control-flow-construct-like type absl::Cleanup which is used for executing a callback on scope exit.
  • container
    The container library contains additional STL-style containers, including Abseil's unordered "Swiss table" containers.
  • debugging
    The debugging library contains code useful for enabling leak checks, and stacktrace and symbolization utilities.
  • hash
    The hash library contains the hashing framework and default hash functor implementations for hashable types in Abseil.
  • memory
    The memory library contains C++11-compatible versions of std::make_unique() and related memory management facilities.
  • meta
    The meta library contains C++11-compatible versions of type checks available within C++14 and C++17 versions of the C++ library.
  • numeric
    The numeric library contains C++11-compatible 128-bit integers.
  • status
    The status contains abstractions for error handling, specifically absl::Status and absl::StatusOr.
  • strings
    The strings library contains a variety of strings routines and utilities, including a C++11-compatible version of the C++17 std::string_view type.
  • synchronization
    The synchronization library contains concurrency primitives (Abseil's absl::Mutex class, an alternative to std::mutex) and a variety of synchronization abstractions.
  • time
    The time library contains abstractions for computing with absolute points in time, durations of time, and formatting and parsing time within time zones.
  • types
    The types library contains non-container utility types, like a C++11-compatible version of the C++17 std::optional type.
  • utility
    The utility library contains utility and helper code.

Releases

Abseil recommends users "live-at-head" (update to the latest commit from the master branch as often as possible). However, we realize this philosophy doesn't work for every project, so we also provide Long Term Support Releases to which we backport fixes for severe bugs. See our release management document for more details.

License

The Abseil C++ library is licensed under the terms of the Apache license. See LICENSE for more information.

Links

For more information about Abseil:

Comments
  • Add CMake support

    Add CMake support

    Initial partial CMake support for abseil, created after the discussion of this afternoon.

    Do not merge yet, this is still incomplete.

    I created the pull request for tracking and avoid duplicated effort.

    Adev

  • to be or not to be: CMake install()

    to be or not to be: CMake install()

    Issue following the discussions on #8 : should we support install() in the cmake build:

    Pro:

    • required by people who do not use cmake in their project.
    • make the usage of package manager possible

    Cons:

    • make easy for to rely on ABI and have problems
  • Add a version number to the library + git tag

    Add a version number to the library + git tag

    Hello,

    I can't see any version number / scheme in the library. Does it exist? It would be nice to have such version numbers reflected via git tags (and probably the cmake file) in order to:

    • clone the repository on a specific tag in order to ensure repeatable builds & environment setup
    • know if a new version has been released and compare what's new regarding the version we are currently using

    That would probably imply to maintain a changelog file as well. It's a bit of more work but it's very useful for consumers like me.

    Aurelien

  • Don't #include <windows.h>

    Don't #include

    Currently it appears to be impossible to compile Abseil using VS 2017 without errors.

    Adding something like this resolve this problem with windows.h includes.

    # ifndef WIN32_LEAN_AND_MEAN
    #   define WIN32_LEAN_AND_MEAN
    # endif
    # ifndef VC_EXTRALEAN
    #   define VC_EXTRALEAN
    # endif
    # ifndef NOMINMAX
    #   define NOMINMAX
    # endif
    #include <windows.h>
    
  • Implement the Parallel Hashmap in Abseil

    Implement the Parallel Hashmap in Abseil

    see https://greg7mdp.github.io/parallel-hashmap/ for writeup.

    The new absl::parallel_flat_hash_map and absl::parallel_flat_hash_set have the same tests as the base maps and all tests pass on Windows (vs2017) and linux (g++ 5.4 and clang 3.8)

  • Cmake links all abseil components and results in a link time error

    Cmake links all abseil components and results in a link time error

    No matter what I try, cmake builds the whole abseil and then links everything into my shared library. I could reproduce this with a minimal cmake example:

    cmake_minimum_required(VERSION 2.8.12)
    project(my_project)
    set(CMAKE_CXX_FLAGS "-std=c++11 -fvisibility=hidden ${CMAKE_CXX_FLAGS}")
    add_subdirectory(abseil-cpp)
    add_library(my_lib SHARED main.cpp)
    include_directories(SYSTEM abseil-cpp)
    target_link_libraries(my_lib absl::hash absl::container)
    

    main.cpp contains only the following:

    #include <absl/container/flat_hash_map.h>
    int foo(void) {
    	absl::flat_hash_map<int,int> m;
    	return 0;
    }
    

    For an actual project where I'm trying to use abseil, I get a linker error in debug mode that says the following:

    /usr/sbin/ld: ../absail/absl/container/libabsl_container.a(raw_hash_set.cc.o): relocation R_X86_64_TPOFF32 against hidden symbol `_ZZN4absl18container_internal10RandomSeedEvE7counter' can not be used when making a shared object
    

    The project in question is here. Top level CmakeLists.txt Shared object defining CMakeLists.txt Abseil, at commit a06c4a1, is a submodule of my project. The build instructions are:

    • Clone bstaletic/ycmd and checkout aseil branch
    • git submodule update --init --recursive
    • mkdir build && cd build
    • cmake ../cpp -DCMAKE_BUILD_TYPE=Debug

    Other build time dependencies are python headers. For python3 -DUSE_PYTHON2=OFF is needed.

  • [Benchmark] flat_hash_map considerably slower than std::unordered_map

    [Benchmark] flat_hash_map considerably slower than std::unordered_map

    This is not a bug report, more of an interesting data point. In the past week I've been trying out absl::flat_hash_map and google::dense_hash_map (and sets) and comparing performance to STL counterparts.

    The following gist contains benchmarks for STL (Master), abseil and dense_hash_map: https://gist.github.com/bstaletic/7d3e31db7fc8d40a12787fab09ff092f

    The project whose benchmark results you're looking at is https://github.com/Valloric/ycmd The benchmarks test two separate algorithms, FilterAndSortCandidates and IdentifierCompleter.

    FilterAndSortCandidates benchmark

    This is benchmarking the function of the same name. This one actually has the best timings with abseil.

    IdentifierCompleter benchmark

    This is benchmarking this piece of code. Surprisingly, abseil is the slowest of the three.

    If there's interest to investigate my benchmark results further, I will gladly provide any information needed.

  • Support using Abseil via CMake find_package

    Support using Abseil via CMake find_package

    Hello,

    I have a bit of trouble using a local Abseil installation, as I dont want to depend on external packages with some fixes URL nor some fixed filesystem paths. Cmake already HAS the necessary infrastructure to allow building dependend modules.

    For using Abseil in your Project, just this would be necessary:

    # cctz pulls in some gtest and benchmark suites otherwise
    set (BUILD_TESTING OFF)
    find_package(Abseil REQUIRED
    )
    

    And, given the worst-case that abseil and cctz are in no directory that can be found automatically, configuration would add the respective paths: cmake -DAbseil_DIR=<local path> -DCctz_DIR=<local path> ...

    Basic support would be added by this patch (note that cctz would need to be fixed in a similar fashion):

    diff --git a/AbseilConfig.cmake b/AbseilConfig.cmake
    new file mode 100644
    index 0000000..4476b98
    --- /dev/null
    +++ b/AbseilConfig.cmake
    @@ -0,0 +1,2 @@
    +# Macros
    +include(${CMAKE_CURRENT_LIST_DIR}/CMake/AbseilMacros.cmake)
    diff --git a/CMake/AbseilMacros.cmake b/CMake/AbseilMacros.cmake
    new file mode 100644
    index 0000000..94c6886
    --- /dev/null
    +++ b/CMake/AbseilMacros.cmake
    @@ -0,0 +1,8 @@
    +# TODO: this should be another find_package(Cctz)
    +add_subdirectory(${Cctz_DIR} _libcctz
    +	EXCLUDE_FROM_ALL
    +)
    +
    +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/.." _libabseil
    +	EXCLUDE_FROM_ALL
    +)
    
  • Fix Randen and PCG on Big Endian platforms

    Fix Randen and PCG on Big Endian platforms

    Randen expects seed and state buffers to be in LE ordering even on BE machines, and PCG is not, but they both use a shared seed implementation which is currently favouring Randen.

    This patch fixes randen_slow to behave the same as RandenHwAes and reverse the byte order when necessary and changes seed generator to be in native byte order.

  • Use the implicitly defaulted constructor

    Use the implicitly defaulted constructor

    Defining an empty default constructor is worse than using the compiler generated constructor.

    Note that the compiler generated constructor requires that constexpr as well as exception specifiers are correctly considered. See Chapter 15.1 [class.ctor] paragraph 7

  • StrReadUntil(string_view&, string_view sep)

    StrReadUntil(string_view&, string_view sep)

    Request for a function like string_view StrReadUntil(string_view&, string_view sep)

    Returns the part until (not including) the separator and removes that part (including separator) from the input (in-place). Returns the entire input and clears it if separator isn't found.

    Examples: StrReadUntil(is, "\n"); // reads next line StrReadUntil(is, ";"); reads next value from 1;2;3

    It's a bit like getline() for string_views.

  • direct_mmap: Use off_t on linux

    direct_mmap: Use off_t on linux

    off64_t is not provided without defining _LARGEFILE64_SOURCE on musl this define is not defined automatically like glibc where it gets defined when _GNU_SOURCE is defined. Using off_t makes it portable across musl/glibc and for using 64bit off_t on glibc 32bit systems -D_FILE_OFFSET_BITS=64 can be defined during build via CXXFLAGS

    Signed-off-by: Khem Raj [email protected]

  • Does not compile on windows (MSVC)

    Does not compile on windows (MSVC)

    As known, (see https://github.com/abseil/abseil-cpp/blob/master/absl/base/internal/atomic_hook.h#L139, https://github.com/abseil/abseil-cpp/issues/659, etc.), MSVC does not provide a constinit std::atomic<T*>.

    But, both https://github.com/abseil/abseil-cpp/blob/master/absl/strings/internal/cordz_handle.cc#L27 and https://github.com/abseil/abseil-cpp/blob/master/absl/strings/internal/cordz_info.cc#L41 attempt to define a ABSL_CONST_INIT object which contain a std::atomic (https://github.com/abseil/abseil-cpp/blob/master/absl/strings/internal/cordz_handle.h#L90, https://github.com/abseil/abseil-cpp/blob/master/absl/strings/internal/cordz_info.h#L196).

    This makes absl not compilable with the latest MSVC.

    I see a macro ABSL_INTERNAL_CORDZ_ENABLED https://github.com/abseil/abseil-cpp/blob/72ec15a317a74cccf03a62f749f3ab28206be069/absl/strings/internal/cordz_functions.h#L47, which is false for MSVC; does this mean cordz_info and cordz_handle are not even needed, as a simple 'fix'? Or do we need a different workaround?

    absl\strings\internal\cordz_info.cc:41:44: error: variable does not have a constant initializer
    ABSL_CONST_INIT CordzInfo::List CordzInfo::global_list_{absl::kConstInit};
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    absl\strings\internal\cordz_info.cc:41:1: note: required by 'require_constant_initialization' attribute here
    ABSL_CONST_INIT CordzInfo::List CordzInfo::global_list_{absl::kConstInit};
    ^~~~~~~~~~~~~~~
    absl/base/attributes.h:714:27: note: expanded from macro 'ABSL_CONST_INIT'
    #define ABSL_CONST_INIT [[clang::require_constant_initialization]]
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ...xxatomic:207:21: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
                    : _Atomic_address{(_ATOMIC_UINT)_Right}
                                      ^
    abseil-cpp\absl/strings/internal/cordz_info.h:196:56: note: in call to 'atomic(nullptr)'
        std::atomic<CordzInfo*> head ABSL_GUARDED_BY(mutex){nullptr};
    
  • absl::MakeSpan for vector, and the common incorrect usages

    absl::MakeSpan for vector, and the common incorrect usages

    absl's MakeSpan takes only pointers, but since vector is very commonly used in C++, I've come across many use-cases where people tried to make a span for a vector in a similar way as array, and the resultant code was actually a UB. The example in the comments is for arrays:

    int array[3] = { 0, 0, 0 };
    // Call with a [begin, end) pair.
    ProcessInts(absl::MakeConstSpan(&array[0], &array[3]));
    

    I've seen many people do the same for vectors, and access the element at index size(), which is UB. A better way to do that might be to use data() method of vectors, like MakeConstSpan(v.data(), v.data() + 3).

    Can we have a comment saying this, or maybe we can add a method with iterators. I think even in the example in the comments, &array[3] might as well be UB, since I'm not sure about accessing the element at the size() index for an array.

    Can you please share your thoughts on this?

  • Unused function

    Unused function

    https://github.com/abseil/abseil-cpp/blob/master/absl/crc/internal/crc_internal.h#L171

    I cannot find in source who use this function (not used in source or tests or benchmarks). But because of it vector and memory included.

    Maybe remove it and unnecessary includes?

  • CRC32C output operator seems not generalized

    CRC32C output operator seems not generalized

    https://github.com/abseil/abseil-cpp/blob/842560d214649fc0077838e5b02cc35e4af12526/absl/crc/crc32c.h#L169

    Firstly, header includes both <iostream> and <ostream>, which seems redundantly. And operator << defined for std::ostream, but not for std::basic_ostream<Char, Traits>. It breakes code like std::wcout << value;

    I dont think output operator is needed generally, atleast in this header

    Also personally i dont see a reason to not make crc32c a type(class) without free functions

Concise CMake templates for creating C++ libraries or executables.

cmake_templates Concise cmake templates for creating C++ libraries and executables. Creating a normal cmake project Copy the chosen project template s

Oct 20, 2022
Abseil Common Libraries (C++)

The repository contains the Abseil C++ library code. Abseil is an open-source collection of C++ code (compliant to C++11) designed to augment the C++ standard library.

Dec 31, 2022
Single-header C11 port of abseil.io's Swiss Table

cwisstable.h cwisstable is a single-header C11 port of the Abseil project's Swiss Tables. This project is intended to bring the proven performance and

Dec 30, 2022
A library with common code used by libraries and tools around the libimobiledevice project

libimobiledevice-glue Library with common code used by the libraries and tools around the libimobiledevice project. Features The main functionality pr

Dec 23, 2022
POCO C++ Libraries are powerful cross-platform C++ libraries for building network
POCO C++ Libraries are powerful cross-platform C++ libraries for building network

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.

Jan 1, 2023
Bolt is a C++ template library optimized for GPUs. Bolt provides high-performance library implementations for common algorithms such as scan, reduce, transform, and sort.

Bolt is a C++ template library optimized for heterogeneous computing. Bolt is designed to provide high-performance library implementations for common

Dec 27, 2022
C++ (with python bindings) library for easily reading/writing/manipulating common animation particle formats such as PDB, BGEO, PTC. See the discussion group @ http://groups.google.com/group/partio-discuss

Partio - A library for particle IO and manipulation This is the initial source code release of partio a tool we used for particle reading/writing. It

Dec 29, 2022
Wangle is a framework providing a set of common client/server abstractions for building services in a consistent, modular, and composable way.

Wangle C++ networking library Wangle is a library that makes it easy to build protocols, application clients, and application servers. It's like Netty

Jan 8, 2023
🔗 Common Data Structures and Algorithms

?? Data Structures and Algorithms This library provides common data structures. It will also provide some data structures which needed in render or ga

Dec 10, 2022
The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application decides at run time which output style should be produced.

libxo libxo - A Library for Generating Text, XML, JSON, and HTML Output The libxo library allows an application to generate text, XML, JSON, and HTML

Dec 10, 2022
Utilities and common code for use with raylib

Utilities and shared components for use with raylib

Dec 1, 2022
A library of common data structures and algorithms written in C.

C Algorithms The C programming language includes a very limited standard library in comparison to other modern programming languages. This is a coll

Jan 9, 2023
Common Lisp and CXX interoperation with JIT
Common Lisp and CXX interoperation  with JIT

CL-CXX-JIT - Common Lisp C++ JIT for exposing C++ functions This library provides an interface to C++ from lisp. It compiles C++ code, then loads it i

Dec 19, 2022
Common Sensor API for the BMA2 family of sensors

BMA2 Sensor API Sensor overview The BMA2 is a triaxial, low-g acceleration sensor with digital output. An ASIC in the sensor converts the output of a

Dec 5, 2022
Common utilities useful for embedded systems that are often not included in an RTOS or the standard C library.
Common utilities useful for embedded systems that are often not included in an RTOS or the standard C library.

Welcome to Fitterbap, the Firmware toolkit to enable reliable best architecture practices! Fitterbap provides common utilities useful for embedded systems that are often not included in an RTOS or the standard C library.

Dec 7, 2022
A fast Python Common substrings of multiple strings library with C++ implementation

A fast Python Common substrings of multiple strings library with C++ implementation Having a bunch of strings, can I print some substrings which appea

Aug 21, 2022
Common Device Source For Xiaomi Redmi Note 5 Pro (whyred)

The Redmi Note 5 Pro (codenamed "whyred") are high-end mid-range smartphones from Xiaomi announced and released in February 2018. Device specification

Dec 22, 2021
Isaac ROS common utilities and scripts for use in conjunction with the Isaac ROS suite of packages.

Isaac ROS Common Isaac ROS common utilities and scripts for use in conjunction with the Isaac ROS suite of packages. Docker Scripts run_dev.sh creates

Jan 8, 2023
A static analysis tool that helps security researchers scan a list of Windows kernel drivers for common vulnerability patterns in drivers (CVE makers!)
A static analysis tool that helps security researchers scan a list of Windows kernel drivers for common vulnerability patterns in drivers (CVE makers!)

Driver Analyzer A static analysis tool that helps security researchers scan a list of Windows kernel drivers for common vulnerability patterns in driv

Sep 3, 2022
Clio is an embryonic experiment in UI for Common Lisp programs.

Clio Clio is an embryonic experiment in UI for Common Lisp programs. Building and running Clio Make sure you have the prerequisites: Visual Studio 201

Feb 26, 2022