-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
111 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Copyright 2025 Glen Joseph Fernandes | ||
([email protected]) | ||
Distributed under the Boost Software License, Version 1.0. | ||
(http://www.boost.org/LICENSE_1_0.txt) | ||
*/ | ||
#ifndef BOOST_CORE_DETAIL_ASSERT_HPP | ||
#define BOOST_CORE_DETAIL_ASSERT_HPP | ||
|
||
#include <cassert> | ||
|
||
#if defined(__GNUC__) && __GNUC__ < 5 && \ | ||
!defined(__clang__) && \ | ||
!defined(__INTEL_COMPILER) | ||
#if defined(NDEBUG) | ||
#define BOOST_CORE_ASSERT(expr) void(0) | ||
#else | ||
#define BOOST_CORE_ASSERT(expr) \ | ||
((expr) ? void(0) : __assert_fail(#expr, __FILE__, __LINE__, 0)) | ||
#endif | ||
#else | ||
#define BOOST_CORE_ASSERT(expr) assert(expr) | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
Copyright 2025 Glen Joseph Fernandes | ||
([email protected]) | ||
Distributed under the Boost Software License, Version 1.0. | ||
(http://www.boost.org/LICENSE_1_0.txt) | ||
*/ | ||
#include <boost/config.hpp> | ||
#if !defined(BOOST_NO_CXX11_CONSTEXPR) | ||
#include <boost/core/span.hpp> | ||
#include <boost/core/lightweight_test.hpp> | ||
|
||
constexpr const int array[4]{ 5, 10, 15, 20 }; | ||
|
||
void test_first() | ||
{ | ||
constexpr boost::span<const int> s = | ||
boost::span<const int>(array, 4).first(2); | ||
BOOST_TEST_EQ(s.data(), &array[0]); | ||
BOOST_TEST_EQ(s.size(), 2); | ||
} | ||
|
||
void test_last() | ||
{ | ||
constexpr boost::span<const int> s = | ||
boost::span<const int>(array, 4).last(2); | ||
BOOST_TEST_EQ(s.data(), &array[2]); | ||
BOOST_TEST_EQ(s.size(), 2); | ||
} | ||
|
||
void test_subspan() | ||
{ | ||
constexpr boost::span<const int> s = | ||
boost::span<const int>(array, 4).subspan(1, 2); | ||
BOOST_TEST_EQ(s.data(), &array[1]); | ||
BOOST_TEST_EQ(s.size(), 2); | ||
} | ||
|
||
void test_index() | ||
{ | ||
constexpr const int i = boost::span<const int>(array, 4)[1]; | ||
BOOST_TEST_EQ(i, 10); | ||
} | ||
|
||
void test_front() | ||
{ | ||
constexpr const int i = boost::span<const int>(array, 4).front(); | ||
BOOST_TEST_EQ(i, 5); | ||
} | ||
|
||
void test_back() | ||
{ | ||
constexpr const int i = boost::span<const int>(array, 4).back(); | ||
BOOST_TEST_EQ(i, 20); | ||
} | ||
|
||
int main() | ||
{ | ||
test_first(); | ||
test_last(); | ||
test_subspan(); | ||
test_index(); | ||
test_front(); | ||
test_back(); | ||
return boost::report_errors(); | ||
} | ||
#else | ||
int main() | ||
{ | ||
return 0; | ||
} | ||
#endif |