forked from ryo-currency/ryo-currency
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The literal operator allows to convert C strings into std::strings
- Loading branch information
1 parent
1e757c7
commit 156164c
Showing
3 changed files
with
106 additions
and
1 deletion.
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
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,49 @@ | ||
// Copyright (c) 2018, Ryo Currency Project | ||
// | ||
// Portions of this file are available under BSD-3 license. Please see ORIGINAL-LICENSE for details | ||
// All rights reserved. | ||
// | ||
// Authors and copyright holders give permission for following: | ||
// | ||
// 1. Redistribution and use in source and binary forms WITHOUT modification. | ||
// | ||
// 2. Modification of the source form for your own personal use. | ||
// | ||
// As long as the following conditions are met: | ||
// | ||
// 3. You must not distribute modified copies of the work to third parties. This includes | ||
// posting the work online, or hosting copies of the modified work for download. | ||
// | ||
// 4. Any derivative version of this work is also covered by this license, including point 8. | ||
// | ||
// 5. Neither the name of the copyright holders nor the names of the authors may be | ||
// used to endorse or promote products derived from this software without specific | ||
// prior written permission. | ||
// | ||
// 6. You agree that this licence is governed by and shall be construed in accordance | ||
// with the laws of England and Wales. | ||
// | ||
// 7. You agree to submit all disputes arising out of or in connection with this licence | ||
// to the exclusive jurisdiction of the Courts of England and Wales. | ||
// | ||
// Authors and copyright holders agree that: | ||
// | ||
// 8. This licence expires and the work covered by it is released into the | ||
// public domain on 1st of February 2019 | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | ||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
#include <string> | ||
|
||
std::string operator ""_s(const char * str, size_t len) { | ||
return std::string(str, len); | ||
} |
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,54 @@ | ||
// Copyright (c) 2018, Ryo Currency Project | ||
// | ||
// Portions of this file are available under BSD-3 license. Please see ORIGINAL-LICENSE for details | ||
// All rights reserved. | ||
// | ||
// Authors and copyright holders give permission for following: | ||
// | ||
// 1. Redistribution and use in source and binary forms WITHOUT modification. | ||
// | ||
// 2. Modification of the source form for your own personal use. | ||
// | ||
// As long as the following conditions are met: | ||
// | ||
// 3. You must not distribute modified copies of the work to third parties. This includes | ||
// posting the work online, or hosting copies of the modified work for download. | ||
// | ||
// 4. Any derivative version of this work is also covered by this license, including point 8. | ||
// | ||
// 5. Neither the name of the copyright holders nor the names of the authors may be | ||
// used to endorse or promote products derived from this software without specific | ||
// prior written permission. | ||
// | ||
// 6. You agree that this licence is governed by and shall be construed in accordance | ||
// with the laws of England and Wales. | ||
// | ||
// 7. You agree to submit all disputes arising out of or in connection with this licence | ||
// to the exclusive jurisdiction of the Courts of England and Wales. | ||
// | ||
// Authors and copyright holders agree that: | ||
// | ||
// 8. This licence expires and the work covered by it is released into the | ||
// public domain on 1st of February 2019 | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | ||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
/** convert a C string into a C++ std::string | ||
* | ||
* @code{cpp} | ||
* auto foo = "Hello World!"_s; // type of foo is std::string | ||
* @endcode | ||
*/ | ||
std::string operator ""_s(const char * str, size_t len); |