Renamed from fixed_string to static_string, added aliases

This commit is contained in:
Krystian Stasiowski
2019-12-16 12:23:46 -05:00
parent c3110b1b6c
commit e26c470c3a
18 changed files with 8598 additions and 8508 deletions

View File

@ -4,7 +4,7 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Official repository: https://github.com/boostorg/fixed_string
# Official repository: https://github.com/boostorg/static_string
#
cmake_minimum_required (VERSION 3.5.1)
@ -36,11 +36,11 @@ endfunction()
#-------------------------------------------------------------------------------
#
# FixedString
# StaticString
#
#-------------------------------------------------------------------------------
project (FixedString VERSION 1)
project (StaticString VERSION 1)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
@ -145,8 +145,8 @@ endif()
#include_directories (.)
file (GLOB_RECURSE PROJECT_FILES
${PROJECT_SOURCE_DIR}/include/boost/fixed_string/*.hpp
${PROJECT_SOURCE_DIR}/include/boost/fixed_string/*.ipp
${PROJECT_SOURCE_DIR}/include/boost/static_string/*.hpp
${PROJECT_SOURCE_DIR}/include/boost/static_string/*.ipp
)
add_subdirectory (test)

View File

@ -4,7 +4,7 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Official repository: https://github.com/boostorg/fixed_string
# Official repository: https://github.com/boostorg/static_string
#
build-project test ;

View File

@ -2,8 +2,8 @@
Branch | Travis | Appveyor | Azure Pipelines | codecov.io | Docs | Matrix |
:-------------: | ------ | -------- | --------------- | ---------- | ---- | ------ |
[`master`](https://github.com/18/static_string/tree/master) | [![Build Status](https://travis-ci.org/18/static_string.svg?branch=master)](https://travis-ci.org/18/static_string) | [![Build status](https://ci.appveyor.com/api/projects/status/64es4wg4w7mc5wn2/branch/master?svg=true)](https://ci.appveyor.com/project/1847325/fixed-string/branch/master) | [![Build Status](https://dev.azure.com/vinniefalco/fixed-string/_apis/build/status/pipeline?branchName=master)](https://dev.azure.com/vinniefalco/fixed-string/_build/latest?definitionId=6&branchName=master) | [![codecov](https://codecov.io/gh/18/static_string/branch/master/graph/badge.svg)](https://codecov.io/gh/18/static_string/branch/master) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](https://18.github.io/doc/static_string) | [![Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/static_string.html)
[`develop`](https://github.com/18/static_string/tree/develop) | [![Build Status](https://travis-ci.org/18/static_string.svg?branch=develop)](https://travis-ci.org/18/static_string) | [![Build status](https://ci.appveyor.com/api/projects/status/64es4wg4w7mc5wn2/branch/develop?svg=true)](https://ci.appveyor.com/project/1847325/fixed-string/branch/develop) | [![Build Status](https://dev.azure.com/vinniefalco/fixed-string/_apis/build/status/pipeline?branchName=develop)](https://dev.azure.com/vinniefalco/fixed-string/_build/latest?definitionId=6&branchName=master) | [![codecov](https://codecov.io/gh/18/static_string/branch/develop/graph/badge.svg)](https://codecov.io/gh/18/static_string/branch/develop) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/static_string.html) | [![Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/static_string.html)
[`master`](https://github.com/18/static_string/tree/master) | [![Build Status](https://travis-ci.org/18/static_string.svg?branch=master)](https://travis-ci.org/18/static_string) | [![Build status](https://ci.appveyor.com/api/projects/status/64es4wg4w7mc5wn2/branch/master?svg=true)](https://ci.appveyor.com/project/1847325/static-string/branch/master) | [![Build Status](https://dev.azure.com/vinniefalco/fixed-string/_apis/build/status/pipeline?branchName=master)](https://dev.azure.com/vinniefalco/fixed-string/_build/latest?definitionId=6&branchName=master) | [![codecov](https://codecov.io/gh/18/static_string/branch/master/graph/badge.svg)](https://codecov.io/gh/18/static_string/branch/master) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](https://18.github.io/doc/static_string) | [![Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/static_string.html)
[`develop`](https://github.com/18/static_string/tree/develop) | [![Build Status](https://travis-ci.org/18/static_string.svg?branch=develop)](https://travis-ci.org/18/static_string) | [![Build status](https://ci.appveyor.com/api/projects/status/64es4wg4w7mc5wn2/branch/develop?svg=true)](https://ci.appveyor.com/project/1847325/static-string/branch/develop) | [![Build Status](https://dev.azure.com/vinniefalco/fixed-string/_apis/build/status/pipeline?branchName=develop)](https://dev.azure.com/vinniefalco/fixed-string/_build/latest?definitionId=6&branchName=master) | [![codecov](https://codecov.io/gh/18/static_string/branch/develop/graph/badge.svg)](https://codecov.io/gh/18/static_string/branch/develop) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/static_string.html) | [![Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/static_string.html)
## Introduction

View File

@ -5,7 +5,7 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
project fixed_string/doc ;
project static_string/doc ;
import os ;
import path ;
@ -23,7 +23,7 @@ import saxonhe ;
# docs can be rebuild if any of the header files change.
#
local sources = [ path.glob-tree ../include/boost/fixed_string : *.hpp *.ipp : detail impl ] ;
local sources = [ path.glob-tree ../include/boost/static_string : *.hpp *.ipp : detail impl ] ;
# Get the configured paths to doxygen and xsltproc
@ -148,12 +148,12 @@ install qbk : reference.qbk ;
install images
:
:
<location>html/fixed_string/images
<location>html/static_string/images
;
explicit images ;
xml fixed_string_doc
xml static_string_doc
:
qbk/main.qbk
:
@ -161,7 +161,7 @@ xml fixed_string_doc
<dependency>qbk
;
explicit fixed_string_doc ;
explicit static_string_doc ;
#-------------------------------------------------------------------------------
#
@ -169,9 +169,9 @@ explicit fixed_string_doc ;
#
#-------------------------------------------------------------------------------
boostbook fixed_string
boostbook static_string
:
fixed_string_doc
static_string_doc
:
<xsl:param>boost.root=../../../..
<xsl:param>chapter.autolabel=1
@ -195,5 +195,5 @@ boostbook fixed_string
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : fixed_string ;
alias boostrelease : static_string ;
explicit boostrelease ;

View File

@ -7,10 +7,10 @@
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Official repository: https://github.com/boostorg/fixed_string
Official repository: https://github.com/boostorg/static_string
-->
<section id="fixed_string.index">
<section id="static_string.index">
<title>Index</title>
<index/>
</section>

View File

@ -5,11 +5,11 @@
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Official repository: https://github.com/boostorg/fixed_string
Official repository: https://github.com/boostorg/static_string
]
[library Boost.FixedString
[id fixed_string]
[library Boost.StaticString
[id static_string]
[quickbook 1.6]
[copyright 2016 - 2019 Vinnie Falco]
[copyright 2019 Krystian Stasiowski]
@ -30,7 +30,6 @@
[template path_link[path name] '''<ulink url="../../'''[path]'''">'''[name]'''</ulink>''']
[template include_file[path][^<'''<ulink url="../../../../'''[path]'''">'''[path]'''</ulink>'''>]]
[template issue[n] '''<ulink url="https://github.com/boostorg/beast/issues/'''[n]'''">#'''[n]'''</ulink>''']
[def __InputIterator__ [@https://en.cppreference.com/w/cpp/named_req/InputIterator ['InputIterator]]]
@ -73,16 +72,16 @@ The over-arching design goal is to resemble the interface and behavior of
maximum allowed size of the string, `std::length_error` is thrown. All
algorithms which throw exceptions provide the strong exception safety
guarantee. This is intended to be a drop in replacement for `std::string`.
All the operations for `fixed_string` work when the source is within the string itself.
All the operations for `static_string` work when the source is within the string itself.
The API of `fixed_string` only diverges from `std::string` in few places,
being `substr` for which this implementation returns a string view instead of `fixed_string`,
The API of `static_string` only diverges from `std::string` in few places,
being `substr` for which this implementation returns a string view instead of `static_string`,
and certain functions that will never throw are marked as `noexcept`, which diverges from
those of `std::string`. Every function that is in the C++20 specification of `std::string` is
present in this implementation, with the only difference being the lack of `constexpr`
for the time being. The avaliable overloads for `fixed_string` are identical to those
for the time being. The avaliable overloads for `static_string` are identical to those
of `std::string`, except for `operator+` which is explicitly deleted as no reasonable implementation
would be possible, due to the difficulty in determining the size of the resulting `fixed_string`.
would be possible, due to the difficulty in determining the size of the resulting `static_string`.
[endsect]

View File

@ -7,7 +7,7 @@
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Official repository: https://github.com/boostorg/fixed_string
Official repository: https://github.com/boostorg/static_string
-->
<informaltable frame="all">

View File

@ -3,7 +3,7 @@
#---------------------------------------------------------------------------
INPUT = \
$(LIB_DIR)/include/boost/fixed_string
$(LIB_DIR)/include/boost/static_string
ALIASES += esafe="@par Exception Safety"
@ -43,7 +43,7 @@ SKIP_FUNCTION_MACROS = YES
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "FixedString"
PROJECT_NAME = "StaticString"
PROJECT_NUMBER =
PROJECT_BRIEF = String Library
PROJECT_LOGO =

View File

@ -1,6 +1,6 @@
<!-- Variables (Edit for your project) -->
<xsl:variable name="doc-ref" select="'fixed_string.ref.'"/>
<xsl:variable name="doc-ns" select="'boost::fixed_string'"/>
<xsl:variable name="doc-ref" select="'static_string.ref.'"/>
<xsl:variable name="doc-ns" select="'boost::static_string'"/>
<xsl:variable name="debug" select="0"/>
<xsl:variable name="private" select="0"/>
<!-- End Variables -->

View File

@ -1,117 +0,0 @@
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
// Copyright (c) 2019 Krystian Stasiowski (sdkrystian at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/fixed_string
//
#ifndef BOOST_FIXED_STRING_CONFIG_HPP
#define BOOST_FIXED_STRING_CONFIG_HPP
// Are we dependent on Boost?
// #define BOOST_FIXED_STRING_STANDALONE
// Can we have deduction guides?
#ifdef __cpp_deduction_guides
#define BOOST_FIXED_STRING_USE_DEDUCT
#endif
// Can we use [[nodiscard]]?
#ifdef __has_attribute
#if __has_attribute(nodiscard)
#define BOOST_FIXED_STRING_NODISCARD [[nodiscard]]
#else
#define BOOST_FIXED_STRING_NODISCARD
#endif
#else
#define BOOST_FIXED_STRING_NODISCARD
#endif
//#undef _<>_<EFBFBD>cplusplus
//#define _<>_<EFBFBD>cplusplus 201703L
#if __cplusplus > 201703L
#define BOOST_FIXED_STRING_CPP20_CXPER constexpr
#define BOOST_FIXED_STRING_CPP17_CXPER constexpr
#define BOOST_FIXED_STRING_CPP14_CXPER constexpr
#define BOOST_FIXED_STRING_CPP11_CXPER constexpr
#define BOOST_FIXED_STRING_CPP20_CXPER_USED
#define BOOST_FIXED_STRING_CPP17_CXPER_USED
#define BOOST_FIXED_STRING_CPP14_CXPER_USED
#define BOOST_FIXED_STRING_CPP11_CXPER_USED
#define BOOST_FIXED_STRING_ALLOW_UNINIT_MEM
#elif __cplusplus >= 201703L
#define BOOST_FIXED_STRING_CPP20_CXPER
#define BOOST_FIXED_STRING_CPP17_CXPER constexpr
#define BOOST_FIXED_STRING_CPP14_CXPER constexpr
#define BOOST_FIXED_STRING_CPP11_CXPER constexpr
#define BOOST_FIXED_STRING_CPP17_CXPER_USED
#define BOOST_FIXED_STRING_CPP14_CXPER_USED
#define BOOST_FIXED_STRING_CPP11_CXPER_USED
#elif __cplusplus >= 201402L
#define BOOST_FIXED_STRING_CPP20_CXPER
#define BOOST_FIXED_STRING_CPP17_CXPER
#define BOOST_FIXED_STRING_CPP14_CXPER constexpr
#define BOOST_FIXED_STRING_CPP11_CXPER constexpr
#define BOOST_FIXED_STRING_CPP14_CXPER_USED
#define BOOST_FIXED_STRING_CPP11_CXPER_USED
#else
#define BOOST_FIXED_STRING_CPP20_CXPER
#define BOOST_FIXED_STRING_CPP17_CXPER
#define BOOST_FIXED_STRING_CPP14_CXPER
#define BOOST_FIXED_STRING_CPP11_CXPER constexpr
#define BOOST_FIXED_STRING_CPP11_CXPER_USED
#endif
#ifndef BOOST_FIXED_STRING_STANDALONE
#include <boost/utility/string_view.hpp>
#include <boost/container_hash/hash.hpp>
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#else
#include <cassert>
#include <string_view>
#endif
// Boost and non-Boost versions of utilities
#ifndef BOOST_FIXED_STRING_STANDALONE
#ifndef BOOST_FIXED_STRING_THROW
#define BOOST_FIXED_STRING_THROW(ex) BOOST_THROW_EXCEPTION(ex)
#endif
#ifndef BOOST_FIXED_STRING_STATIC_ASSERT
#define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) BOOST_STATIC_ASSERT_MSG(cond, msg)
#endif
#ifndef BOOST_FIXED_STRING_ASSERT
#define BOOST_FIXED_STRING_ASSERT(cond) BOOST_ASSERT(cond)
#endif
#else
#ifndef BOOST_FIXED_STRING_THROW
#define BOOST_FIXED_STRING_THROW(ex) throw ex
#endif
#ifndef BOOST_FIXED_STRING_STATIC_ASSERT
#define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
#endif
#ifndef BOOST_FIXED_STRING_ASSERT
#define BOOST_FIXED_STRING_ASSERT(cond) assert(cond)
#endif
#endif
namespace boost {
namespace fixed_string {
/// The type of `basic_string_view` used by the library
template<typename CharT, typename Traits>
using basic_string_view =
#ifndef BOOST_FIXED_STRING_STANDALONE
boost::basic_string_view<CharT, Traits>;
#else
std::basic_string_view<CharT, Traits>;
#endif
} // fixed_string
} // boost
#endif

View File

@ -0,0 +1,117 @@
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
// Copyright (c) 2019 Krystian Stasiowski (sdkrystian at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/static_string
//
#ifndef BOOST_STATIC_STRING_CONFIG_HPP
#define BOOST_STATIC_STRING_CONFIG_HPP
// Are we dependent on Boost?
// #define BOOST_STATIC_STRING_STANDALONE
// Can we have deduction guides?
#ifdef __cpp_deduction_guides
#define BOOST_STATIC_STRING_USE_DEDUCT
#endif
// Can we use [[nodiscard]]?
#ifdef __has_attribute
#if __has_attribute(nodiscard)
#define BOOST_STATIC_STRING_NODISCARD [[nodiscard]]
#else
#define BOOST_STATIC_STRING_NODISCARD
#endif
#else
#define BOOST_STATIC_STRING_NODISCARD
#endif
//#undef _<>_<EFBFBD>cplusplus
//#define _<>_<EFBFBD>cplusplus 201703L
#if __cplusplus > 201703L
#define BOOST_STATIC_STRING_CPP20_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP17_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP14_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP11_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP20_CONSTEXPR_USED
#define BOOST_STATIC_STRING_CPP17_CONSTEXPR_USED
#define BOOST_STATIC_STRING_CPP14_CONSTEXPR_USED
#define BOOST_STATIC_STRING_CPP11_CONSTEXPR_USED
#define BOOST_STATIC_STRING_ALLOW_UNINIT_MEM
#elif __cplusplus >= 201703L
#define BOOST_STATIC_STRING_CPP20_CONSTEXPR
#define BOOST_STATIC_STRING_CPP17_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP14_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP11_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP17_CONSTEXPR_USED
#define BOOST_STATIC_STRING_CPP14_CONSTEXPR_USED
#define BOOST_STATIC_STRING_CPP11_CONSTEXPR_USED
#elif __cplusplus >= 201402L
#define BOOST_STATIC_STRING_CPP20_CONSTEXPR
#define BOOST_STATIC_STRING_CPP17_CONSTEXPR
#define BOOST_STATIC_STRING_CPP14_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP11_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP14_CONSTEXPR_USED
#define BOOST_STATIC_STRING_CPP11_CONSTEXPR_USED
#else
#define BOOST_STATIC_STRING_CPP20_CONSTEXPR
#define BOOST_STATIC_STRING_CPP17_CONSTEXPR
#define BOOST_STATIC_STRING_CPP14_CONSTEXPR
#define BOOST_STATIC_STRING_CPP11_CONSTEXPR constexpr
#define BOOST_STATIC_STRING_CPP11_CONSTEXPR_USED
#endif
#ifndef BOOST_STATIC_STRING_STANDALONE
#include <boost/utility/string_view.hpp>
#include <boost/container_hash/hash.hpp>
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#else
#include <cassert>
#include <string_view>
#endif
// Boost and non-Boost versions of utilities
#ifndef BOOST_STATIC_STRING_STANDALONE
#ifndef BOOST_STATIC_STRING_THROW
#define BOOST_STATIC_STRING_THROW(ex) BOOST_THROW_EXCEPTION(ex)
#endif
#ifndef BOOST_STATIC_STRING_STATIC_ASSERT
#define BOOST_STATIC_STRING_STATIC_ASSERT(cond, msg) BOOST_STATIC_ASSERT_MSG(cond, msg)
#endif
#ifndef BOOST_STATIC_STRING_ASSERT
#define BOOST_STATIC_STRING_ASSERT(cond) BOOST_ASSERT(cond)
#endif
#else
#ifndef BOOST_STATIC_STRING_THROW
#define BOOST_STATIC_STRING_THROW(ex) throw ex
#endif
#ifndef BOOST_STATIC_STRING_STATIC_ASSERT
#define BOOST_STATIC_STRING_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
#endif
#ifndef BOOST_STATIC_STRING_ASSERT
#define BOOST_STATIC_STRING_ASSERT(cond) assert(cond)
#endif
#endif
namespace boost {
namespace static_string {
/// The type of `basic_string_view` used by the library
template<typename CharT, typename Traits>
using basic_string_view =
#ifndef BOOST_STATIC_STRING_STANDALONE
boost::basic_string_view<CharT, Traits>;
#else
std::basic_string_view<CharT, Traits>;
#endif
} // static_string
} // boost
#endif

View File

@ -5,23 +5,23 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/fixed_string
// Official repository: https://github.com/boostorg/static_string
//
#ifndef BOOST_FIXED_STRING_DETAIL_FIXED_STRING_HPP
#define BOOST_FIXED_STRING_DETAIL_FIXED_STRING_HPP
#ifndef BOOST_STATIC_STRING_DETAIL_STATIC_STRING_HPP
#define BOOST_STATIC_STRING_DETAIL_STATIC_STRING_HPP
#include <boost/fixed_string/config.hpp>
#include <boost/static_string/config.hpp>
#include <iterator>
#include <type_traits>
#include <limits>
namespace boost {
namespace fixed_string {
namespace static_string {
namespace detail {
template<std::size_t, typename, typename>
class fixed_string;
class basic_static_string;
// At minimum an integral type shall not qualify as an iterator (Agustin Berge)
template<class T>
@ -41,44 +41,44 @@ using smallest_width =
// Optimization for using the smallest possible type
template<std::size_t N, typename CharT, typename Traits>
class fixed_string_base_zero
class static_string_base_zero
{
public:
BOOST_FIXED_STRING_CPP11_CXPER
fixed_string_base_zero() noexcept { };
BOOST_STATIC_STRING_CPP11_CONSTEXPR
static_string_base_zero() noexcept { };
BOOST_FIXED_STRING_CPP11_CXPER
fixed_string_base_zero(std::size_t n) noexcept : size_(n) { }
BOOST_STATIC_STRING_CPP11_CONSTEXPR
static_string_base_zero(std::size_t n) noexcept : size_(n) { }
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
CharT*
data_impl() noexcept
{
return data_;
}
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
CharT const*
data_impl() const noexcept
{
return data_;
}
BOOST_FIXED_STRING_CPP11_CXPER
BOOST_STATIC_STRING_CPP11_CONSTEXPR
std::size_t
size_impl() const noexcept
{
return size_;
}
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
std::size_t
set_size(std::size_t n) noexcept
{
return size_ = n;
}
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
term_impl() noexcept
{
@ -86,7 +86,7 @@ public:
}
smallest_width<N> size_{0};
#ifdef BOOST_FIXED_STRING_ALLOW_UNINIT_MEM
#ifdef BOOST_STATIC_STRING_ALLOW_UNINIT_MEM
CharT data_[N + 1];
#else
CharT data_[N + 1]{};
@ -95,14 +95,14 @@ public:
// Optimization for when the size is 0
template<typename CharT, typename Traits>
class fixed_string_base_zero<0, CharT, Traits>
class static_string_base_zero<0, CharT, Traits>
{
public:
BOOST_FIXED_STRING_CPP11_CXPER
fixed_string_base_zero() noexcept { }
BOOST_STATIC_STRING_CPP11_CONSTEXPR
static_string_base_zero() noexcept { }
BOOST_FIXED_STRING_CPP11_CXPER
fixed_string_base_zero(std::size_t) noexcept { }
BOOST_STATIC_STRING_CPP11_CONSTEXPR
static_string_base_zero(std::size_t) noexcept { }
// not possible to constexpr with the static there
CharT*
@ -112,21 +112,21 @@ public:
return &null;
}
BOOST_FIXED_STRING_CPP11_CXPER
BOOST_STATIC_STRING_CPP11_CONSTEXPR
std::size_t
size_impl() const noexcept
{
return 0;
}
BOOST_FIXED_STRING_CPP11_CXPER
BOOST_STATIC_STRING_CPP11_CONSTEXPR
std::size_t
set_size(std::size_t) noexcept
{
return 0;
}
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
term_impl() noexcept
{
@ -136,58 +136,58 @@ public:
// Optimization for storing the size in the last element
template<std::size_t N, typename CharT, typename Traits>
class fixed_string_base_null
class static_string_base_null
{
public:
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string_base_null() noexcept { set_size(0); }
BOOST_STATIC_STRING_CPP14_CONSTEXPR
static_string_base_null() noexcept { set_size(0); }
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string_base_null(std::size_t n) noexcept { set_size(n); }
BOOST_STATIC_STRING_CPP14_CONSTEXPR
static_string_base_null(std::size_t n) noexcept { set_size(n); }
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
CharT*
data_impl() noexcept
{
return data_;
}
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
CharT const*
data_impl() const noexcept
{
return data_;
}
BOOST_FIXED_STRING_CPP11_CXPER
BOOST_STATIC_STRING_CPP11_CONSTEXPR
std::size_t
size_impl() const noexcept
{
return N - data_[N];
}
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
std::size_t
set_size(std::size_t n) noexcept
{
return data_[N] = (N - n);
}
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
term_impl() noexcept
{
Traits::assign(data_[size_impl()], 0);
}
#ifdef BOOST_FIXED_STRING_ALLOW_UNINIT_MEM
#ifdef BOOST_STATIC_STRING_ALLOW_UNINIT_MEM
CharT data_[N + 1];
#else
CharT data_[N + 1]{};
#endif
};
//#define BOOST_FIXED_STRING_NO_NULL_OPTIMIZATION
//#define BOOST_STATIC_STRING_NO_NULL_OPTIMIZATION
// Decides which size optimization to use
// If the size is zero, the object will have no members
@ -195,12 +195,12 @@ public:
// Otherwise, store the size of the string using a member of the smallest type possible
template<std::size_t N, typename CharT, typename Traits>
using optimization_base =
#ifndef BOOST_FIXED_STRING_NO_NULL_OPTIMIZATION
#ifndef BOOST_STATIC_STRING_NO_NULL_OPTIMIZATION
typename std::conditional<(N <= (std::numeric_limits<CharT>::max)()) && (N != 0),
fixed_string_base_null<N, CharT, Traits>,
fixed_string_base_zero<N, CharT, Traits>>::type;
static_string_base_null<N, CharT, Traits>,
static_string_base_zero<N, CharT, Traits>>::type;
#else
fixed_string_base_zero<N, CharT, Traits>;
static_string_base_zero<N, CharT, Traits>;
#endif
template<typename CharT, typename Traits>
@ -234,7 +234,7 @@ template<std::size_t N, typename CharT, typename Traits >
inline
int
lexicographical_compare(
const fixed_string<N, CharT, Traits>& s1,
const basic_static_string<N, CharT, Traits>& s1,
CharT const* s2, std::size_t n2)
{
return detail::lexicographical_compare<
@ -256,8 +256,8 @@ template<std::size_t N, std::size_t M, typename CharT, typename Traits>
inline
int
lexicographical_compare(
const fixed_string<N, CharT, Traits>& s1,
const fixed_string<M, CharT, Traits>& s2)
const basic_static_string<N, CharT, Traits>& s1,
const basic_static_string<M, CharT, Traits>& s2)
{
return detail::lexicographical_compare<CharT, Traits>(
s1.data(), s1.size(), s2.data(), s2.size());
@ -326,7 +326,7 @@ inline
CharT*
raw_to_string(CharT* last, std::size_t size, Integer i)
{
BOOST_FIXED_STRING_ASSERT(size >= max_digits(sizeof(Integer)));
BOOST_STATIC_STRING_ASSERT(size >= max_digits(sizeof(Integer)));
return raw_to_string<CharT, Integer, Traits>(
last, i, std::is_signed<Integer>{});
}
@ -347,7 +347,7 @@ find_not_of(
}
} // detail
} // fixed_string
} // static_string
} // boost
#endif

View File

@ -5,17 +5,17 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/fixed_string
// Official repository: https://github.com/boostorg/static_string
//
#ifndef BOOST_FIXED_STRING_IMPL_FIXED_STRING_HPP
#define BOOST_FIXED_STRING_IMPL_FIXED_STRING_HPP
#ifndef BOOST_STATIC_STRING_IMPL_STATIC_STRING_HPP
#define BOOST_STATIC_STRING_IMPL_STATIC_STRING_HPP
#include <boost/fixed_string/config.hpp>
#include <boost/fixed_string/detail/fixed_string.hpp>
#include <boost/static_string/config.hpp>
#include <boost/static_string/detail/static_string.hpp>
namespace boost {
namespace fixed_string {
namespace static_string {
//------------------------------------------------------------------------------
//
@ -24,28 +24,28 @@ namespace fixed_string {
//------------------------------------------------------------------------------
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP11_CXPER
fixed_string<N, CharT, Traits>::
fixed_string() noexcept
BOOST_STATIC_STRING_CPP11_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string() noexcept
{
#ifdef BOOST_FIXED_STRING_CPP20_CXPER_USED
#ifdef BOOST_STATIC_STRING_CPP20_CONSTEXPR_USED
term();
#endif
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(size_type count, CharT ch)
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(size_type count, CharT ch)
{
assign(count, ch);
}
template<std::size_t N, typename CharT, typename Traits>
template<std::size_t M>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(fixed_string<M, CharT, Traits> const& other,
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(basic_static_string<M, CharT, Traits> const& other,
size_type pos)
{
assign(other, pos);
@ -53,10 +53,10 @@ fixed_string(fixed_string<M, CharT, Traits> const& other,
template<std::size_t N, typename CharT, typename Traits>
template<std::size_t M>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(
fixed_string<M, CharT, Traits> const& other,
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(
basic_static_string<M, CharT, Traits> const& other,
size_type pos,
size_type count)
{
@ -64,21 +64,21 @@ fixed_string(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(CharT const* s, size_type count)
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(CharT const* s, size_type count)
{
assign(s, count);
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(CharT const* s)
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(CharT const* s)
{
auto const count = Traits::length(s);
if(count > max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"count > max_size()"});
this->set_size(count);
Traits::copy(data(), s, size() + 1);
@ -86,9 +86,9 @@ fixed_string(CharT const* s)
template<std::size_t N, typename CharT, typename Traits>
template<class InputIterator>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(
InputIterator first,
InputIterator last,
typename std::enable_if<
@ -99,45 +99,45 @@ fixed_string(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(
fixed_string const& s) noexcept
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(
basic_static_string const& s) noexcept
{
assign(s);
}
template<std::size_t N, typename CharT, typename Traits>
template<std::size_t M>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(
fixed_string<M, CharT, Traits> const& s)
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(
basic_static_string<M, CharT, Traits> const& s)
{
assign(s);
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(std::initializer_list<CharT> init)
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(std::initializer_list<CharT> init)
{
assign(init.begin(), init.end());
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(string_view_type sv)
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(string_view_type sv)
{
assign(sv);
}
template<std::size_t N, typename CharT, typename Traits>
template<class T, class>
BOOST_FIXED_STRING_CPP14_CXPER
fixed_string<N, CharT, Traits>::
fixed_string(T const& t, size_type pos, size_type n)
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string<N, CharT, Traits>::
basic_static_string(T const& t, size_type pos, size_type n)
{
assign(t, pos, n);
}
@ -149,16 +149,16 @@ fixed_string(T const& t, size_type pos, size_type n)
//------------------------------------------------------------------------------
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
assign(
size_type count,
CharT ch) ->
fixed_string&
basic_static_string&
{
if(count > max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"count > max_size()"});
this->set_size(count);
Traits::assign(data(), size(), ch);
@ -167,12 +167,12 @@ assign(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
assign(
fixed_string const& s) noexcept ->
fixed_string&
basic_static_string const& s) noexcept ->
basic_static_string&
{
if(this == &s)
return *this;
@ -186,30 +186,30 @@ assign(
template<std::size_t N, typename CharT, typename Traits>
template<std::size_t M>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
assign(
fixed_string<M, CharT, Traits> const& s,
basic_static_string<M, CharT, Traits> const& s,
size_type pos,
size_type count) ->
fixed_string&
basic_static_string&
{
auto const ss = s.subview(pos, count);
return assign(ss.data(), ss.size());
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
assign(
CharT const* s,
size_type count) ->
fixed_string&
basic_static_string&
{
if(count > max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"count > max_size()"});
this->set_size(count);
Traits::move(data(), s, size());
@ -219,19 +219,19 @@ assign(
template<std::size_t N, typename CharT, typename Traits>
template<class InputIterator>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
assign(
InputIterator first,
InputIterator last) ->
typename std::enable_if<
detail::is_input_iterator<InputIterator>::value,
fixed_string&>::type
basic_static_string&>::type
{
std::size_t const n = std::distance(first, last);
if(n > max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"n > max_size()"});
this->set_size(n);
for(auto it = data(); first != last; ++it, ++first)
@ -247,27 +247,27 @@ assign(
//------------------------------------------------------------------------------
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
at(size_type pos) ->
reference
{
if(pos >= size())
BOOST_FIXED_STRING_THROW(std::out_of_range{
BOOST_STATIC_STRING_THROW(std::out_of_range{
"pos >= size()"});
return data()[pos];
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
at(size_type pos) const ->
const_reference
{
if(pos >= size())
BOOST_FIXED_STRING_THROW(std::out_of_range{
BOOST_STATIC_STRING_THROW(std::out_of_range{
"pos >= size()"});
return data()[pos];
}
@ -279,13 +279,13 @@ at(size_type pos) const ->
//------------------------------------------------------------------------------
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
reserve(std::size_t n)
{
if(n > max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"n > max_size()"});
}
@ -296,9 +296,9 @@ reserve(std::size_t n)
//------------------------------------------------------------------------------
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
clear() noexcept
{
this->set_size(0);
@ -308,39 +308,39 @@ clear() noexcept
//------------------------------------------------------------------------------
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
insert(
size_type index,
size_type count,
CharT ch) ->
fixed_string&
basic_static_string&
{
if(index > size())
BOOST_FIXED_STRING_THROW(std::out_of_range{
BOOST_STATIC_STRING_THROW(std::out_of_range{
"index > size()"});
insert(begin() + index, count, ch);
return *this;
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
insert(
size_type index,
CharT const* s,
size_type count) ->
fixed_string&
basic_static_string&
{
const auto curr_size = size();
const auto curr_data = data();
if(index > curr_size)
BOOST_FIXED_STRING_THROW(std::out_of_range{
BOOST_STATIC_STRING_THROW(std::out_of_range{
"index > size()"});
if(count > max_size() - curr_size)
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"size() + count > max_size()"});
const bool inside = s <= &curr_data[curr_size] && s >= curr_data;
if (!inside || (inside && ((s - curr_data) + count <= index)))
@ -368,9 +368,9 @@ insert(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
insert(
const_iterator pos,
size_type count,
@ -380,7 +380,7 @@ insert(
const auto curr_size = size();
const auto curr_data = data();
if(count > max_size() - curr_size)
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"size() + count() > max_size()"});
auto const index = pos - curr_data;
Traits::move(&curr_data[index + count], &curr_data[index], curr_size - index);
@ -392,9 +392,9 @@ insert(
template<std::size_t N, typename CharT, typename Traits>
template<class InputIterator>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
insert(
const_iterator pos,
InputIterator first,
@ -409,9 +409,9 @@ insert(
template<std::size_t N, typename CharT, typename Traits>
template<class T>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
insert(
size_type index,
T const & t) ->
@ -419,7 +419,7 @@ insert(
std::is_convertible<
T const&, string_view_type>::value &&
! std::is_convertible<
T const&, CharT const*>::value, fixed_string&
T const&, CharT const*>::value, basic_static_string&
>::type
{
return insert(index, t, 0, npos);
@ -427,9 +427,9 @@ insert(
template<std::size_t N, typename CharT, typename Traits>
template<class T>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
insert(
size_type index,
T const & t,
@ -439,7 +439,7 @@ insert(
std::is_convertible<
T const&, string_view_type>::value &&
! std::is_convertible<
T const&, CharT const*>::value, fixed_string&
T const&, CharT const*>::value, basic_static_string&
>::type
{
auto const s =
@ -450,18 +450,18 @@ insert(
//------------------------------------------------------------------------------
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
erase(
size_type index,
size_type count) ->
fixed_string&
basic_static_string&
{
const auto curr_size = size();
const auto curr_data = data();
if(index > curr_size)
BOOST_FIXED_STRING_THROW(std::out_of_range{
BOOST_STATIC_STRING_THROW(std::out_of_range{
"index > size()"});
auto const n = (std::min)(count, curr_size - index);
Traits::move(&curr_data[index], &curr_data[index + n], curr_size - (index + n) + 1);
@ -470,9 +470,9 @@ erase(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
erase(
const_iterator pos) ->
iterator
@ -482,9 +482,9 @@ erase(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
erase(
const_iterator first,
const_iterator last) ->
@ -496,15 +496,15 @@ erase(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
push_back(
CharT ch)
{
const auto curr_size = size();
if(curr_size >= max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"size() >= max_size()"});
Traits::assign(data()[curr_size], ch);
this->set_size(curr_size + 1);
@ -512,17 +512,17 @@ push_back(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
append(
CharT const* s,
size_type count) ->
fixed_string&
basic_static_string&
{
const auto curr_size = size();
if(count > max_size() - curr_size)
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"size() + count > max_size()"});
Traits::copy(&data()[curr_size], s, count);
this->set_size(curr_size + count);
@ -531,35 +531,35 @@ append(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
substr(size_type pos, size_type count) const ->
fixed_string
basic_static_string
{
if(pos > size())
BOOST_FIXED_STRING_THROW(std::out_of_range{
BOOST_STATIC_STRING_THROW(std::out_of_range{
"pos > size()"});
return {&data()[pos], (std::min)(count, size() - pos)};
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
subview(size_type pos, size_type count) const ->
string_view_type
{
if (pos > size())
BOOST_FIXED_STRING_THROW(std::out_of_range{
BOOST_STATIC_STRING_THROW(std::out_of_range{
"pos > size()"});
return {&data()[pos], (std::min)(count, size() - pos)};
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
copy(CharT* dest, size_type count, size_type pos) const noexcept ->
size_type
{
@ -569,14 +569,14 @@ copy(CharT* dest, size_type count, size_type pos) const noexcept ->
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
resize(std::size_t n)
{
const auto curr_size = size();
if(n > max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"n > max_size()"});
if(n > curr_size)
Traits::assign(&data()[curr_size], n - curr_size, CharT{});
@ -585,14 +585,14 @@ resize(std::size_t n)
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
resize(std::size_t n, CharT c)
{
const auto curr_size = size();
if(n > max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"n > max_size()"});
if(n > curr_size)
Traits::assign(&data()[curr_size], n - curr_size, c);
@ -601,13 +601,13 @@ resize(std::size_t n, CharT c)
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
fixed_string<N, CharT, Traits>::
swap(fixed_string& s) noexcept
basic_static_string<N, CharT, Traits>::
swap(basic_static_string& s) noexcept
{
const auto curr_size = size();
fixed_string tmp(s);
basic_static_string tmp(s);
s.set_size(curr_size);
Traits::copy(&s.data()[0], data(), curr_size + 1);
this->set_size(tmp.size());
@ -616,19 +616,19 @@ swap(fixed_string& s) noexcept
template<std::size_t N, typename CharT, typename Traits>
template<std::size_t M>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
void
fixed_string<N, CharT, Traits>::
swap(fixed_string<M, CharT, Traits>& s)
basic_static_string<N, CharT, Traits>::
swap(basic_static_string<M, CharT, Traits>& s)
{
const auto curr_size = size();
if(curr_size > s.max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"size() > s.max_size()"});
if(s.size() > max_size())
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"s.size() > max_size()"});
fixed_string tmp(s);
basic_static_string tmp(s);
s.set_size(curr_size);
Traits::copy(&s.data()[0], data(), curr_size + 1);
this->set_size(tmp.size());
@ -636,22 +636,22 @@ swap(fixed_string<M, CharT, Traits>& s)
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
replace(
size_type pos,
size_type n1,
const CharT* s,
size_type n2) -> fixed_string<N, CharT, Traits>&
size_type n2) -> basic_static_string<N, CharT, Traits>&
{
const auto curr_size = size();
const auto curr_data = data();
if (pos > curr_size)
BOOST_FIXED_STRING_THROW(std::out_of_range{
BOOST_STATIC_STRING_THROW(std::out_of_range{
"pos > size()"});
if (curr_size - (std::min)(n1, curr_size - pos) >= max_size() - n2)
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"replaced string exceeds max_size()"});
if (pos + n1 >= curr_size)
n1 = curr_size - pos;
@ -693,22 +693,22 @@ replace(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
replace(
size_type pos,
size_type n1,
size_type n2,
CharT c) -> fixed_string<N, CharT, Traits> &
CharT c) -> basic_static_string<N, CharT, Traits> &
{
const auto curr_size = size();
const auto curr_data = data();
if (pos > curr_size)
BOOST_FIXED_STRING_THROW(std::out_of_range{
BOOST_STATIC_STRING_THROW(std::out_of_range{
"pos > size()"});
if (curr_size - (std::min)(n1, curr_size - pos) >= max_size() - n2)
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"replaced string exceeds max_size()"});
if (pos + n1 >= curr_size)
n1 = curr_size - pos;
@ -719,9 +719,9 @@ replace(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
find(
const CharT* s,
size_type pos,
@ -738,9 +738,9 @@ find(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
rfind(
const CharT* s,
size_type pos,
@ -762,9 +762,9 @@ rfind(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
find_first_of(
const CharT* s,
size_type pos,
@ -779,9 +779,9 @@ find_first_of(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
find_last_of(
const CharT* s,
size_type pos,
@ -800,9 +800,9 @@ find_last_of(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
find_first_not_of(
const CharT* s,
size_type pos,
@ -818,9 +818,9 @@ find_first_not_of(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
find_last_not_of(
const CharT* s,
size_type pos,
@ -838,11 +838,11 @@ find_last_not_of(
}
template<std::size_t N, typename CharT, typename Traits>
BOOST_FIXED_STRING_CPP14_CXPER
BOOST_STATIC_STRING_CPP14_CONSTEXPR
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
assign_char(CharT ch, std::true_type) noexcept ->
fixed_string&
basic_static_string&
{
this->set_size(1);
Traits::assign(data()[0], ch);
@ -852,27 +852,27 @@ assign_char(CharT ch, std::true_type) noexcept ->
template<std::size_t N, typename CharT, typename Traits>
auto
fixed_string<N, CharT, Traits>::
basic_static_string<N, CharT, Traits>::
assign_char(CharT, std::false_type) ->
fixed_string&
basic_static_string&
{
BOOST_FIXED_STRING_THROW(std::length_error{
BOOST_STATIC_STRING_THROW(std::length_error{
"max_size() == 0"});
}
template<class Integer, class>
inline
fixed_string<detail::max_digits(sizeof(Integer))>
to_fixed_string(Integer x)
basic_static_string<detail::max_digits(sizeof(Integer)), char>
to_static_string(Integer x)
{
using CharT = char;
using Traits = std::char_traits<CharT>;
BOOST_FIXED_STRING_STATIC_ASSERT(std::is_integral<Integer>::value, "Integer must be an integral type");
BOOST_STATIC_STRING_STATIC_ASSERT(std::is_integral<Integer>::value, "Integer must be an integral type");
char buf[detail::max_digits(sizeof(Integer))];
auto last = buf + sizeof(buf);
auto it = detail::raw_to_string<
CharT, Integer, Traits>(last, sizeof(buf), x);
fixed_string<detail::max_digits(sizeof(Integer))> s;
basic_static_string<detail::max_digits(sizeof(Integer)), char> s;
s.resize(static_cast<std::size_t>(last - it));
auto p = s.data();
while(it < last)
@ -880,7 +880,7 @@ to_fixed_string(Integer x)
return s;
}
} // fixed_string
} // static_string
} // boost
#endif

View File

@ -1,14 +1,14 @@
<html>
<head>
<title>Boost.FixedString</title>
<meta http-equiv="refresh" content="0; URL=https://18.github.io/doc/fixed_string/">
<title>Boost.StaticString</title>
<meta http-equiv="refresh" content="0; URL=https://18.github.io/doc/static_string/">
</head>
<body>
Automatic redirection failed, please go to
<a href="https://18.github.io/doc/fixed_string/">https://18.github.io/doc/fixed_string/</a>
<a href="https://18.github.io/doc/static_string/">https://18.github.io/doc/static_string/</a>
<hr>
<tt>
Boost.FixedString<br>
Boost.StaticString<br>
<br>
Copyright&nbsp;(C)&nbsp;2019&nbsp;Vinnie&nbsp;Falco<br>
Copyright&nbsp;(C)&nbsp;2019&nbsp;Krystian&nbsp;Stasiowski<br>

View File

@ -4,16 +4,16 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Official repository: https://github.com/boostorg/fixed_string
# Official repository: https://github.com/boostorg/static_string
#
GroupSources (include/boost/fixed_string fixed_string)
GroupSources (include/boost/static_string static_string)
GroupSources (test "/")
add_executable (tests
${PROJECT_FILES}
Jamfile
fixed_string.cpp
static_string.cpp
)
target_link_libraries(tests

View File

@ -4,7 +4,7 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Official repository: https://github.com/boostorg/fixed_string
# Official repository: https://github.com/boostorg/static_string
#
import testing ;
@ -22,4 +22,4 @@ local defines =
project : requirements $(defines) ;
run fixed_string.cpp ;
run static_string.cpp ;

File diff suppressed because it is too large Load Diff